A function which zips a list onto itself can be defined as:
let adjacent1 l = zip l $ tail l
This works, but I'd like to define it in pointfree style. To do this, I define a function dollarize
:
let dollarize f1 f2 x = f1 x $ f2 x
let adjacent1 = dollarize zip tail
This works, but obviously I'd rather not define my own higher-order functions. Is there a way to find the standard equivalent of dollarize
, assuming it exists? And if not, where are the functions of this sort which exist to combine functions?
The pointfree
tool can do this for you automagically.
$ pointfree "\l -> zip l (tail l)"
ap zip tail
$ pointfree "\f1 f2 x -> f1 x $ f2 x"
ap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With