Is there HashTable structure in Wolfram Mathematica?

后端 未结 5 1640
暖寄归人
暖寄归人 2021-01-31 11:21

I want to use a Structure like HashTable. Is there similar structure in Wolfram Mathematica?

5条回答
  •  悲&欢浪女
    2021-01-31 11:53

    Mathematica 10 introduces Association, <| k -> v |>,

    <|a -> x, b -> y, c -> z|>
    %[b]
    y
    

    Which is basically a wrapper for a list of rules: Convert a list of rules to an association:

    Association[{a -> x, b -> y, c -> z}]
    <|a -> x, b -> y, c -> z|>
    

    Convert an association to a list of rules:

    Normal[<|a -> x, b -> y, c -> z|>]
    {a -> x, b -> y, c -> z}
    

提交回复
热议问题