Re: Associative array

new topic     » goto parent     » topic index » view thread      » older message » newer message
menno said...

I have here example of a implementation of a Associative array (Content-addressable memory) , maybe usefull for somebody ...

Euphoria (v4) already has an implementation of AA; its called a map in Eu4.

For example ...

include std/console.e 
include std/map.e 
object myMap = map:new() 
 
map:put(myMap, "ID",      "DerekParnell")  
map:put(myMap, "Family",  "Parnell")  
map:put(myMap, "Name",    "Derek")  
map:put(myMap, "Phone",   "555 1234")  
map:put(myMap, "Address", "42 Main Street")  
map:put(myMap, "City",    "Downtown")  
 
display( map:keys(myMap) ) 
display( map:values(myMap) ) 
 

Gives the output of ...

{ 
  "ID", 
  "Family", 
  "Name", 
  "Phone", 
  "Address", 
  "City" 
} 
{ 
  "DerekParnell", 
  "Parnell", 
  "Derek", 
  "555 1234", 
  "42 Main Street", 
  "Downtown" 
} 

Have a look at the map docs for more details.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu