Bill Allombert on Fri, 13 Mar 2015 19:23:23 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

PARI Map object


Dear PARI developers,

We have added support for associative arrays ("maps") to PARI.
This work this way:

M=Map() creates an empty map.
mapput(M,x,y) add a new binding x->y to the map
mapget(M,x) retry the value associated to x.
mapdelete(M,x) remove x from the domain of M.

maps can be converted to matrices with Mat and conversely
matrices with two columns can be converter to maps with Map.
Vec can be also sued to retry the domain of the map.

? M = Map();
? mapput(M,"foo",23);
? mapput(M,7718,"bill");
? mapget(M,"foo")
%4 = 23
? mapget(M,7718)
%5 = "bill"
? Vec(M)
%6 = [7718, "foo"]
? Mat(M)
%7 =
[ 7718 "bill"]

["foo"     23]
? Vec(M)
%8 = [7718, "foo"]

Cheers,
Bill