GolFunc

GolFunc is a functional golfing language made by User:Joaozin003 to make certain code golfing challenges easier.
== Basic concepts ==
To print, we use the pre-defined function P, which obviously prints our value. Strings are opened and optionally closed with double quotes. So let's try it!
 P"Hello, World!
Wait, what? It doesn't work because you need the . operator to apply functions. So here we actually go!
 .P"Hello, World!
And it does work! The dot will come in handy later to help us golf our code.
For many reasons, strings are actually lists of characters. Characters are made with a single quote followed by their value.
So if we want to print a single "a", we can do:
 .P'a
And it saves bytes over:
 .P"a"
And like strings, for many reasons, characters are treated as unsigned integers.
But wait! How do we print them as numbers?
You can represent the number 48 as the character '0, and you can print it as a number using the function O:
 .O'0
Which prints 48. You can represent single-digit numbers with their digit:
 .O7
Which prints 7.
We can do basic arithmetic with +, -, *, / and % (remainder or modulo):
 .O..*68
Which also prints 48. See the massive use of the dot? It's to completely eliminate the need for parentheses in this language!
But what do P and O actually return? They return an N (same as None or null in other languages). They hold no value and is also treated as the identity function.
Speaking of functions, how do we make them? Abstraction is done by typing a backtick and then the variable you're abstracting. But wait! If we don't delimit our abstraction, it will go on forever! So abstractions are optionally delimited by a backslash. Also, in strings, the only characters you need to escape are the double quotes, escaped with single quotes.
If I wanted to make a function that is the same thing as this function in Haskell:
 (\a b c d->a(b c)d)
I would do:
 `a`b`c`d..a.bcd\
Note that we need only one backslash, because it always encloses the outermost abstraction. Also, functions are printed in their golfed form. Also, no. Numbers are NOT church numerals. So you cannot apply numbers to numbers to multiply them. The equivalent functionality would be the : function, which DOES act like church numerals.
Free variables are interpreted as N. So this:
 .Pa
and this:
 .PN
are the same programs. N is printed as N (obviously).
Booleans are denoted with T and F and printed as that. They have the functions !, &, | and ^ for boolean operations, doing the same thing you would expect them to. These DO act like church booleans, so ..T12 results in 1.
Other data types will be discussed later.
== Lists ==
Lists are opened and optionally closed by square brackets and have no item delimiter because it's not needed. A list is interpreted as a right-fold list, a.k.a. [12] is sugar for `f`x..f1..f2x\, which means lists have Haskell's foldr already implemented into themselves.
== Preset functions ==
In the table below, the first letter of the name of the required type is listed as the argument. x and y stand for "any type". f and g stand for "function". "m" also stands for number.
These functions are already made for you:
 .Px prints x as chars and returns N.
 .On prints n as a number and returns N.
 .Nx returns x.
 .Rl reverses a list.
 ...,xyf equals ..fxy. Used for pairing values.
 ...Bfgx equals .f.gx. Used for composing functions.
 ..+mn returns m+n.
 ..-mn returns m-n.
 ..*mn returns m*n.
 ../mn returns m/n.
 ..%mn returns the remainder of m/n.
 ...:nfx calls the function f n times on x.
 ..Cll concatenates two lists.
 ..Txy returns x.
 ..Fxy returns y.
 .Ix takes a char from input once x is evaluated and returns that. Ignores value of x.
 .Jx takes a number from input once x is evaluated and returns that. Ignores value of x.
 .Lx takes a line from input once x is evaluated and returns that. Ignores value of x.
 .Yf equals .f.Yf.
 ...Sxyz equals ..xz.yz.
== Notes ==
You can comment the rest of a line with #.
== Example programs ==
=== Hello World ===
 .P"Hello, World!
 
Prints "Hello, World!" (without quotes) with a new line after it.
=== Truth Machine ===
 .....:.JN.TTF.O0.Y.O1
Ungolfed:
 .
 .
 .
 .
 .
 :
 .JN
 .TT
 F
 .O0
 .Y
 .O1
If the input is zero, it prints a single zero, otherwise it prints infinite ones.
Category:Languages Category:2023 Category:Functional paradigm Category:Golfing language