Functional Programming
From Federal Burro of Information
notes from the field.
In general,
new_collection = collection.map(function)
is a short-cut for:
new_collection[] for (element in collection) new_collection[] += function(element)
And:
new_collection = collection.filter(function)
is a short-cut for:
new_collection[] for (element in collection): if function(element): new_collection[] += function(element)
this
doubled = [1, 2, 3, 4, 5].map(x => x * 2)
is equivalent to:
doubled[] for (x in [1, 2, 3, 4, 5]): doubled[] += x * 2
that