echo "x:xs => ".S("SATURN")->to_a()->head().':'.S("SATURN")->to_a()->tail()."\n"; # creating a Hash (H) is much like creating an Array # the Hash class is actually named H # the H() function does not accept the KEY => VALUE syntax, but instead accepts a parameter list of alternating KEY, VALUE, parameters # the new H(array(...)) syntax does accept KEY => VALUE notation but with the drawback that KEYs must be defined using native types. $h = H(S("SATURN"), 1, 'hello', 2, 'goodbye', 3, 'fatty', 0); $h = new H(array("SATURN" => 1, 'hello' => 2, 'goodbye' => 3, 'fatty' => 0)); echo "hash = ".$h."\n"; # the each() iterator for hashes pass a 2-pair array containing at offset 0 the KEY and offset 1 the VALUE i.e. A($key, $value) $h->each(function($x) { echo ">> each() $x <<\n"; }); # the each_pair() function is an alias of each_with_index() passing each key,value pair to the callback function $h->each_pair(function($x,$y) { echo ">> each_pair() key={$x} value={$y} <<\n"; }); # there are many other methods # please refer to the code within the lib/ directory for now # each class is broken up into seperate files function quicksort($xs) { if($xs->count() < 2) return $xs; $p = $xs->head();