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

Content deleted Content added
m Minor corrections
Lusum (talk | contribs)
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">
<pre>
m = [("Sally Smart", "555-9999"), ("John Doe", "555-1212"), ("J. Random Hacker", "553-1337")]
 
main = print (lookup "John Doe" m)
</presource>
output:
Just "555-1212"
Line 325:
One is polymorphic functional maps (represented as immutable balanced binary trees):
 
<source lang="haskell">
<pre>
import qualified Data.Map as M
 
Line 333:
 
main = print (M.lookup "John Doe" m'' :: Maybe String)
</presource>
output:
Just "555-1212"
Line 341:
Finally, a polymorphic hash table:
 
<source lang="haskell">
<pre>
import qualified Data.HashTable as H
 
Line 350:
foo <- H.lookup m "John Doe"
print foo
</presource>
output:
Just "555-1212"