Lists and Hashes

The HelloWorld sample shows examples of using lists and hashes.

This is a list sample:
 
 list<string> mylist 
 mylist.append( "hello" ) 
 mylist.append( "there," ) 
 mylist.append( "how are" ) 
 mylist.append( "you?" ) 
 foreach item in mylist: 
     p "%s ", (*item).c_str() 
 
This is a hash sample:
 
 map<string,double> grades 
 grades["John"] = 2.4 
 grades["Melinda"] = 3.7 
 grades["Juan"] = 3.4 
 foreach grade in grades: 
     p "%s has a grade of %g\n", grade->key.c_str(), grade->value 
 


NEXT: Download Rascal and take it for a spin