Content deleted Content added
m Minor corrections |
→Haskell: +haskell source tag |
||
Line 311:
The [[Haskell (programming language)|Haskell]] programming language's report only provides one kind of associative container: a list of pairs:
<source lang="haskell">
m = [("Sally Smart", "555-9999"), ("John Doe", "555-1212"), ("J. Random Hacker", "553-1337")]
main = print (lookup "John Doe" m)
</
output:
Just "555-1212"
Line 325:
One is polymorphic functional maps (represented as immutable balanced binary trees):
<source lang="haskell">
import qualified Data.Map as M
Line 333:
main = print (M.lookup "John Doe" m'' :: Maybe String)
</
output:
Just "555-1212"
Line 341:
Finally, a polymorphic hash table:
<source lang="haskell">
import qualified Data.HashTable as H
Line 350:
foo <- H.lookup m "John Doe"
print foo
</
output:
Just "555-1212"
|