Re:Practical functional programming in JavaScript
by ionfish on Thursday July 05, 2012 @04:55AM
(#4202258)
Of course it would. Patches which improved the documentation would be very welcome.
Re:Practical functional programming in JavaScript
by peteretep on Thursday July 05, 2012 @02:42AM
(#4202014)
Also it seems a bit weird to have 'any' and 'filter' without having 'first'.
Re:Practical functional programming in JavaScript
by ostso on Thursday July 05, 2012 @03:53AM
(#4202151)
Not really -- "any" and "filter" are total functions, but "first" of an empty list is undefined.
On the other hand, that also applies to foldl1 and {max,min}imum{,By}, so it's probably not the reason.
The reason is probably that in JavaScript you can just say a[0] to get the first element element of a.
Re:Practical functional programming in JavaScript
by ionfish on Thursday July 05, 2012 @05:04AM
(#4202281)
It seemed unnecessary, yes, although I suppose there are possibly some circumstances where one might want a `first` function—for example if one were folding over a list of lists.
Re:Practical functional programming in JavaScript
by 286c8cb04bda on Thursday July 05, 2012 @11:37AM
(#4203482)
There are an infinite number of circumstances where one would want 'first'.
In Lisp terms[1], 'first' is 'car', which, in conjunction with 'cdr'. With that combination recursive logic is regularly implemented.
[1] Some Lisps already include this alias.
Re:Practical functional programming in JavaScript
by dllthomas on Thursday July 05, 2012 @12:46PM
(#4203751)
In most cases the "a[0]" approach works, however. The set of circumstances where you want "first" as a proper function is limited to those cases where you need to pass it into some higher order function (which is still infinite, granted, but it's not 'every time we'd want "car"').
If a reader knows what the words in the description mean, then presumably they know what currying is...
Wouldn't it be better to have documentation that illuminated, rather than showed off your grasp of programming terms?