Take Or Leave Functional Programming
I appreciate orthogonality in programming. If you name a method in your app “out,” I might expect its pair-opposite, “in” to appear. Even more interesting, I enjoy seeing the implementation of “in” referencing “out” in some way (or visa versa).
most have a
take method. But I can’t find a
leave method anywhere.
So, here’s an introduction to
leave, what it does, why you need it, and
why it balances
sum in a
map instead of
add because he wants to
bind a couple of other parameters.
The poor n00b expected an array
[4, 5] but instead created all kinds of errors
["41,2", "61,2"] and can’t figure out why.
Array.prototype.slice but always starting at
0 index of an array. So,
list.take( x ) should have the same output as
list.slice( 0, x ).
We can use
leave to “guard” the parameters passed from
leave will only
leave one spot open to the signature of
For fun, click the “repl” link below and change the code to
...leave( 2 ).... Why did that happen?
Try it in the repl