Cheddar
Cheddar copied to clipboard
Feature request: Functional operators
There should be an operator that curries a function. Perhaps ~:?
let add = ~: (x, y, z) -> x + y * z;
print(add(3)(4)(5)); // 23
A memoizing function/operator. E.g.:
let fib = memo(n -> n < 2 ? n : fib(n - 1) + fib(n - 2))
fib(1000); // takes however long
fib(1000); // takes virtually no time
Dynamic programing FTW!
I wonder if any more should be considered.
Another idea: (N ~ f)(*a) is the same as calling f(*a,...*a) where *a is repeated N times.
Currying: a => b => a+b => f(a, b) IIRC
Memoise: should be easy to do.
Memoize is easy but it's another thing if you don't want to use a hell ton of memory. Cyrrying is the otherway btw
Some more revisions/additions:
F * n is function repetition. E.g., (F*3)(4) = F(F(F(4)))
F ** n is function argument repetition. E.g., (F**2)(2,3) = F(2,3,2,3)
@ConorOBrien-Foxx can I plz make another porpoisal with that? ;3 (I will credit you)
porpisal
you spelt porpoisal wrong :P
@vihanb fixed
@schas002 uh, okay?