-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathassoc0.html
14 lines (14 loc) · 1.13 KB
/
assoc0.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Association lists are a simple key/value data structure, consisting of a list of pairs. Keys are looked up in the association list by linearly scanning the list, which makes association lists inefficient for large numbers of entries.
Arc's <a href="table.html">tables</a> are an alternative to association lists. Some <a href="http://ycombinator.com/arc/tut.txt">advantages</a> of association lists are that they can preserve order and preserve old values. Also, multiple association lists can share the same tail.
<p>
For more information on association lists, see <a href="http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node153.html">Common Lisp the Language</a>. Unlike Common Lisp association lists that are built out of dotted pairs, Arc association lists are built out of list pairs.
<p>
Arc includes functions for looking up keys in an association list, but no explicit support for building association lists. The lists, however, are simple to create and extend:
<pre class="repl">
arc> (= al '((key1 val1) (key2 val2)))
((key1 val1) (key2 val2))
arc> (push '(key3 val3) al)
((key3 val3) (key1 val1) (key2 val2))
arc> (alref al 'key1)
val1
</pre>