Content deleted Content added
→Lua: copy editing |
→Mathematica and Wolfram Language: copy editing and linking |
||
Line 1,027:
</syntaxhighlight>
===
[[Mathematica]]
▲Mathematica uses the Association<ref>{{cite web|url=https://reference.wolfram.com/language/ref/Association.html|title=Association (<-...->)—Wolfram Language Documentation|website=reference.wolfram.com}}</ref> expression to represent associative arrays.
<syntaxhighlight lang="mathematica">
phonebook = <| "Sally Smart" -> "555-9999",
Line 1,035 ⟶ 1,036:
"J. Random Hacker" -> "553-1337" |>;
</syntaxhighlight>
To access:<ref>{{cite web|url=https://reference.wolfram.com/language/ref/Key.html|title=Key—Wolfram Language Documentation|website=reference.wolfram.com}}</ref>
<syntaxhighlight lang="mathematica">
phonebook[[Key["Sally Smart"]]]
</syntaxhighlight>
If the keys are strings, the
<syntaxhighlight lang="mathematica">
phonebook[["Sally Smart"]]
</syntaxhighlight>
To list keys:<ref>{{cite web|url=https://reference.wolfram.com/language/ref/Keys.html|title=Keys—Wolfram Language Documentation|website=reference.wolfram.com}}</ref> and values<ref>{{cite web|url=https://reference.wolfram.com/language/ref/Values.html|title=Values—Wolfram Language Documentation|website=reference.wolfram.com}}</ref>
Keys[phonebook]
|