by akavi · 13y ago · 0 comments
var totals = splat(get('total'))(orders);
is definitely nicer than var totals = orders.map(function(o){return o.total;});
But there really is not much difference between the coffeescript versions (actually, I'd argue the 'map' version is much clearer in intent): totals = splat(get('total'))(orders);
totals = orders.map (o)->o.total var totals = orders.map(function(o){return o.total;});
far easier to understand than var totals = splat(get('total'))(orders);
And, I would had written var totals = orders.map(function(o){
return o.total
})
(note the lack of semicolons and indentation)cheers!
Do you mean you wanted to emphasize HOFs?
Though I guess that's just a difference in perspective.
Edit: Having stumbled upon something else you wrote[1](Viz. "WHy the crazy idea of using a splatter instead of a mapping method or function?"), I now understand the reason you're making the distinction. Though (speaking as someone who certainly doesn't have the level of expertise to be making this semantic argument) I really don't think it's the distinction between "functional" and "not functional" so much as... "composability"?
[1] https://github.com/raganwald/homoiconic/blob/master/2013/01/...
totals = map (.total), orders
http://livescript.net/Meh.
totals = map (! "total") orders splat('.total')
But you didn't hear it from me.