Ruby:
ruby-1.9.2-p0 > def m
ruby-1.9.2-p0 ?> {:name => "Karl", :age => 42}
ruby-1.9.2-p0 ?> end
ruby-1.9.2-p0 > m
=> {:name=>"Karl", :age=>42}
ruby-1.9.2-p0 >
Clojure:
user> def p
{:name "Fred", :age 42}
#'user/p
user> p
{:name "Fred", :age 42}
Ruby:
ruby-1.9.2-p0 > class Person
ruby-1.9.2-p0 ?> attr :name,:age
ruby-1.9.2-p0 ?> attr_writer :name,:age
ruby-1.9.2-p0 ?> end
ruby-1.9.2-p0 > p = Person.new
=> #
ruby-1.9.2-p0 > p.name="fred";p.age=42;
ruby-1.9.2-p0 > [p,p,p].map &:name
=> ["fred", "fred", "fred"]
Clojure:
user> map :name [p,p,p]
("Fred" "Fred" "Fred")
;;or
user> defrecord Person [name,age]
user.Person
user> def p
Person. "Fred", 42
#'user/p
user> map :name [p, p, p]
("Fred" "Fred" "Fred")
Ruby:
ruby-1.9.2-p0 > [p,p,p].map(&:age).reduce(&:+)
=> 126
Clojure:
reduce +
map :age [p p p] => 126
;;or
->> [p p p]
map :age
reduce +