Content deleted Content added
m →Lisp |
links to articles |
||
Line 500:
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]] ===
<source lang=C>
Line 528:
LPC drivers modern enough to support a foreach() construct allow iteration over their mapping types using it.
=== [[Lua programming language|Lua]] ===
In
The keys and values can be of any type, except nil. The following focuses on non-numerical indexes.
Line 592:
</source>
=== [[MUMPS]] ===
In
applies to private, process-specific arrays stored in memory called "locals" as well as to the permanent, shared arrays stored on disk which are available concurrently by multiple jobs. The name for globals is preceded by the circumflex "^" to distinguish it from local variable names.
Line 666:
</source>
=== [[OCaml]] ===
The
<source lang=OCaml>
Line 715:
Lists of pairs and functional maps both provide a purely functional interface. In contrast, hash tables provide an imperative interface. For many operations, hash tables are significantly faster than lists of pairs and functional maps.
===
{{Refimprove section|date=February 2011}}
The
<source lang=Java>
Line 752:
</source>
=== [[Perl]] ===
A hash variable is marked by a <code>%</code> [[sigil (computer programming)|sigil]], to distinguish it from scalar, array and other data types. A hash literal is a key-value list, with the preferred form using Perl's <code>=></code> token, which is mostly semantically identical to the comma and makes the key-value association clearer:
Line 807:
</source>
=== [[PHP]] ===
An associative array can be declared using the following syntax:
Line 850:
If you want an associative array that can use objects as keys instead of strings and integers, you can use the [http://php.net/SplObjectStorage SplObjectStorage] class from the Standard PHP Library (SPL).
=== [[Pike (programming language)|Pike]] ===
<source lang=Pike>
Line 887:
</source>
=== [[PostScript]] ===
In
<code>
Line 949:
MyDict /rouge undef</code>
=== [[Python (programming language)|Python]] ===
In
<source lang=Python>
Line 996:
</source>
=== [[REXX]] ===
In
<source lang=REXX>
Line 1,018:
</source>
keys are stored in a separate associative array with numeric keys.
=== [[Ruby programming language|Ruby]] ===
In
<source lang=Ruby>
Line 1,048:
</source>
=== [[S-Lang (programming language)|S-Lang]] ===
For example:
Line 1,079:
</source>
=== [[Scala (programming language)|Scala]] ===
<source lang=Scala>
Line 1,096:
This returns an Option type, Scala's equivalent of a [[Monad_(functional_programming)#The Maybe_monad|the Maybe monad]] in Haskell.
=== [[Smalltalk]] ===
In
<source lang=Smalltalk>
Line 1,120:
[[Garbage collection (computer science)#Strong and Weak references|strong references]] to both key and value. Variants exist which hash/compare on identity (IdentityDictionary) or keep [[Garbage collection (computer science)#Strong and Weak references|weak references]] (WeakKeyDictionary / WeakValueDictionary).
=== [[SNOBOL]] ===
Associative arrays in [[SNOBOL]] are called Tables.
Line 1,184:
=== [[Tcl]] ===
There are two
array is a collection of ''variables''. A '''dict''' is a full implementation
of associative arrays.
Line 1,256:
</source>
=== [[Visual Basic]] ===
There is no standard implementation common to all dialects.
<source lang=VB>
Line 1,282:
</source>
=== [[Windows PowerShell|PowerShell]] ===
Unlike many other [[command line interpreter]]s,
For example:
Line 1,371:
Many data serialization formats also support associative arrays (see [[Comparison of data serialization formats#Syntax comparison of human-readable formats|this table]])
=== [[JSON]] ===
Keys can only be strings
<source lang=JavaScript>
Line 1,381:
</source>
=== [[YAML]] ===
<source lang=YAML>
|