Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
Lisp: copy editing
Lisp: copy editing
Line 853:
</syntaxhighlight>
 
Because of their linear nature, alists are used for relatively small sets of data. [[Common Lisp]] also supports a [[hash table]] data type, and for [[Scheme (programming language)|Scheme]] they are implemented in [[Scheme Requests for Implementation|SRFI]] 69. Hash tables have greater overhead than alists, but provide much faster access when there are many elements. A further characteristic mark lies inis the fact that Common Lisp hash tables do not, as opposed to association lists, maintain the order of entry insertion.
 
Common Lisp hash tables are constructed via the <code>make-hash-table</code> function, whose arguments encompass, among other configurations, a predicate to test the entry key against. While tolerating arbitrary objects, even of heterogeneity inwithin a single hash table instance, the specification of this key <code>:test</code> function confinesis theconfined to distinguishable entities: Thethe Common Lisp standard only mandates the support of <code>eq</code>, <code>eql</code>, <code>equal</code>, and <code>equalp</code>, yet designating additional or custom operations as permissive for concrete implementations.
 
<syntaxhighlight lang=Lisp>
Line 864:
</syntaxhighlight>
 
The <code>gethash</code> function permits obtention ofobtaining the value associated with a key.
 
<syntaxhighlight lang=Lisp>
Line 870:
</syntaxhighlight>
 
Additionally, an optionala default value for the case of an absent key may be specified.
 
<syntaxhighlight lang=Lisp>
Line 876:
</syntaxhighlight>
 
An invocation of <code>gethash</code> actually returns two values: the value or substitute value for the key and a boolean indicator, resolving toreturning <code>T</code> if the hash table contains the key and <code>NIL</code> to signal its absence.
 
<syntaxhighlight lang=Lisp>
Line 891:
</syntaxhighlight>
 
<code>clrhash</code> completely empties the complete hash table.
 
<syntaxhighlight lang=Lisp>
Line 897:
</syntaxhighlight>
 
The dedicated <code>maphash</code> function isspecializes specialized onin iterating hash tables.
 
<syntaxhighlight lang=Lisp>
Line 906:
</syntaxhighlight>
 
Alternatively, the <code>loop</code> construct makes provisions for iterations, either over thethrough keys, values, or the conjunctions of both.
 
<syntaxhighlight lang=Lisp>
Line 921:
</syntaxhighlight>
 
A further option comprises the invocation ofinvokes <code>with-hash-table-iterator</code>, an iterator-creating macro, the processing of which is intended to be driven by the caller.
 
<syntaxhighlight lang=Lisp>
Line 932:
</syntaxhighlight>
 
It is easy to construct composite abstract data types in Lisp, using structures and/or the object-oriented programming features, in conjunction with lists, arrays, and hash tables.
 
=== [[LPC (programming language)|LPC]] ===