Lamfunc is a functional esolang by User:PythonshellDebugwindow.
Lamfunc uses a mapping of variable names to values (e.g., a dictionary/associative array) stored in VARS. There is no limit on the amount of name-value pairs in VARS at any one time.
Lamfunc programs are made up of a series of function calls and function definitions.
To call a function, you write its name followed by any arguments, as this is a prefix language, so what would in Python look like
f(g(x(), y()), h()); i() would look like this in Lamfunc:
f g x y h i
To define a function, you write
F fname - code on its own line. (All function definitions are one line, and there are no nested function definitions.) To define a function called
f that calls itself forever:
F f - f
c that takes two arguments and calls them both (either with
b on its own or as an argument to
a, depending on a's arg count):
F c a b - a b
Function redefinitions are invalid syntax.
If a function name fname is preceded by a period
., it will not be called, but instead it will return the function
fname without immediately calling it. So this function is the identity function:
F id f - .f
Lamfunc has eight builtin functions:
ptakes one argument, prints it (prints its bits if given a number), and returns it.
eqtakes two arguments, returns 1 if they are equal, else returns 0.
itakes three arguments; if the first argument is nonzero (see
eq), it returns the second argument, otherwise it returns the third argument.
cbtakes two numbers, combines their bits, and returns that.
lbtakes a number and returns its last bit.
fbtakes a number and returns all but its last bit.
vstakes two arguments X and Y, sets VARS[X] to Y, and returns Y.
vgtakes an argument X, and returns VARS[X] (or 0 for VARS[X] = undefined).
If there aren't enough arguments passed to a function inside a function definition, a lambda function will be returned that takes the rest of that function's required arguments and then calls it. As an example, say you have a function
f that takes 3 arguments and prints them all, this function:
F example a b - f a b
and this call:
example .p .eq .i
would call example with .p and .eq, but example would need another argument. So it would be called with .i, calling f with the three functions and therefore printing them.
While loop function
F _w c f - f while .c .f F while c f - i c _w .c .f eq .i .eq
'Not' function (e.g. !x)
F not x - eq x eq .i .eq