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

Content deleted Content added
Lisp: copy editing and linking
Lisp: copy editing
Line 760:
</syntaxhighlight>
 
Searching for an entry by its key is performed via <code>assoc</code>, which might be configured regardingfor the test predicate and direction, especially searching the association list from its end to its front. The result, if positive, returns the entire entry cons, not only its value. Failure to obtain a matching key leds to a return of the <code>NIL</code> value.
 
<syntaxhighlight lang=Lisp>
Line 766:
</syntaxhighlight>
 
Two generalizations of <code>assoc</code> exist: <code>assoc-if</code> expects a predicate function testingthat tests each entry's key instead of directly specifying the desiderated key, returning the first entry for which the predicate produces a non-<code>NIL</code> value upon invocation. <code>assoc-if-not</code> inverts the logic, accepting the same arguments, but replying withreturning the first entry generating <code>NIL</code>.
 
<syntaxhighlight lang=Lisp>
Line 806:
</syntaxhighlight>
 
All of the above explicatedprevious entry search functions can be replaced by general list-centric variants, thatsuch is,as <code>find</code>, <code>find-if</code>, <code>find-if-not</code>, as well as pertinent functions like <code>position</code> and its derivates.
 
<syntaxhighlight lang=Lisp>
Line 823:
</syntaxhighlight>
 
Iteration is accomplished bywith the aid of any function expectingthat expects a list.
 
<syntaxhighlight lang=Lisp>
Line 839:
</syntaxhighlight>
 
BeingThese a particularlybeing structured listlists, processing and transformation operations can be applied without constraints.
 
<syntaxhighlight lang=Lisp>