let list_of_array arr =
        match arr with
        | RMapValue(h, ArraySubtype-> (
                                match Hashtbl.find h "length" with
                                | RIntegerValue(0) ->[]
                                | RIntegerValue(len) ->
                                                let rec loop lst ind =
                                                        (let lst = (Hashtbl.find h (string_of_int ind)):: lst in
                                                                if ind = 0 then lst else (loop lst (ind - 1)))
                                                in loop [] (len - 1)
                                | _ -> raise (RuntimeError.InternalError "inconsistent array/length not found")
                        )
        | _ -> raise (RuntimeError.InternalError "inconsistent array/not an array")