NSPL
NSPL copied to clipboard
Head and tail
Hello
I notice that there are no head
and tail
equivalents for functional programming. I did notice that there is a first
and a drop($sequence, 1)
, which are equivalent in functionality. Perhaps it would be interesting to simply alias these two? They make implementing recursion in a functional way somewhat more expressive.
Also, thanks for this neat library! Of all the libraries that have some functional programming functionality, I must say this one seems the most extensive up until now. I even decided to prioritize implementing use statement generation for qualified functions and constants in Serenata (PHP language server) to smoothen use of this library.
Apparently init
is also missing, which returns all elements but the last, so it's the reverse of last
and does what tail
does, but for the last instead of the first element.
See also here or this very enlightening picture (by Miran Lipovača):
Hey! Thanks for your suggestions. The functions are missing because I never needed them. I started this library when I was also working with Python and tried to copy some of the things I liked to PHP (and fix the weird API of the standard library).
I'll review @tominventisbe 's PRs this weekend.
@ihor I suppose "this weekend" has already passed, and there are 3 PRs open that seem nice :-) Not that I need them right this instant or something, but for completion of the library's sake, could you review them? I like the zip-one for instance.
@ihor I can help maintain the library if you do not have the time.