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

Content deleted Content added
Pike: copy editing, etc.
PostScript: copy editing
Line 1,420:
</syntaxhighlight>
 
=== PostScript ===
In [[PostScript]], associative arrays are called dictionaries. In Level 1 PostScript they must be created explicitly, but Level 2 introduced direct declaration using thea double-braceangled-bracket syntax:
 
<syntaxhighlight lang="postscript">
Line 1,440:
% Both methods leave the dictionary on the operand stack
</syntaxhighlight>
 
Dictionaries can be accessed directly, using '''<code>get'''</code>, or implicitly, by placing the dictionary on the dictionary stack using '''<code>begin'''</code>:
 
<syntaxhighlight lang="postscript">
Line 1,451 ⟶ 1,452:
</syntaxhighlight>
 
Dictionary contents can be iterated through using '''<code>forall'''</code>, though not in any particular order:
 
<syntaxhighlight lang="postscript">
Line 1,461 ⟶ 1,462:
>> {exch =print ( is ) print ==} forall
</syntaxhighlight>
 
MayWhich wellmay output:
 
<syntaxhighlight lang="postscript">
That is 2
Line 1,468 ⟶ 1,471:
</syntaxhighlight>
 
Dictionaries can be augmented (up to their defined size only in Level 1) or altered using '''<code>put'''</code>, and entries can be removed using '''<code>undef'''</code>:
<syntaxhighlight lang="postscript">
% define a dictionary for easy reuse: