Content deleted Content added
→Lisp: slight copy editing |
→LPC: copy editing and linking |
||
Line 934:
It is easy to construct composite abstract data types in Lisp, using structures or object-oriented programming features, in conjunction with lists, arrays, and hash tables.
===
[[LPC (programming language)|LPC]] implements associative arrays as a fundamental type known as either "map" or "mapping", depending on the driver. The keys and values can be of any type. A mapping literal is written as <code>([ key_1 : value_1, key_2 : value_2 ])</code>. Procedural
<syntaxhighlight lang=C>
Line 946:
Mappings are accessed for reading using the indexing operator in the same way as they are for writing, as shown above. So phone_book["Sally Smart"] would return the string "555-9999", and phone_book["John Smith"] would return 0. Testing for presence is done using the function member(), e.g. <code>if(member(phone_book, "John Smith")) write("John Smith is listed.\n");</code>
Deletion is accomplished using a function called either m_delete() or map_delete(), depending on the driver
LPC drivers of the
<syntaxhighlight lang=C>
Line 960:
</syntaxhighlight>
LPC drivers modern enough to support a foreach() construct
=== [[Lua programming language|Lua]] ===
|