examples: update association_list

This commit is contained in:
darkf 2014-05-28 18:39:46 -07:00
parent c5a29ef171
commit 989db3dc10
1 changed files with 2 additions and 2 deletions

View File

@ -2,7 +2,7 @@
map_insert(assoc, pair) -> pair :: assoc. map_insert(assoc, pair) -> pair :: assoc.
-- lookup by key -- lookup by key
map_lookup([], _) -> ("nothing"). map_lookup([], _) -> ("nothing",).
map_lookup((k,v)::xs, key) -> map_lookup((k,v)::xs, key) ->
if k == key then ("just", v) if k == key then ("just", v)
else map_lookup(xs, key). else map_lookup(xs, key).
@ -21,5 +21,5 @@ m = map_insert(m, ("ready", "go")).
print(m). print(m).
print(map_remove(m, "k")). print(map_remove(m, "k")).
("just", x) = map_lookup(m, "hi"). ("just", x) = map_lookup(m, "hi").
("nothing") = map_lookup(m, "foo"). ("nothing",) = map_lookup(m, "foo").
print(x). print(x).