I'm playing around with guile to try and get familiar with pure functional programming concepts. Before I can do anything useful with any language, I need to understand some basic data structures and how to manipulate them effectively... in particular, enumerable data structures.
I can iterate a list like this (I'm not sure if I'm indenting this correctly or not):
(map (lambda (v)
(display (string-append v "\n"))
'(1 2 3))
=>
1
2
3
What does a hash table/hash map look like in scheme? Is there a real data structure to represent one, or do it come down to making a list of lists? In which case, how do you get the key and value as separate variables from the inner list?
Obviously this is wrong, since the lambda expects one value, not two:
(map (lambda (key value)
(display (string-append key " => " value))
'('("one" 1) '("two" 2) '("three" 3)))
The Ruby equivalent of what I'm trying to do would be:
{ "one" => 1, "two" => 2, "three" => 3 }.map do |key, value|
puts "#{key} => #{value}"
end