Sometimes the best way to learn something is through a series of examples. So here we go.
Here's a program that does absolutely nothing. It's just an empty file. It's the simplest possible Fexl program, though not particularly useful.
This program prints "Hello world" to the screen:
say "Hello world"
Now let's do some math. We'll add 2 and 3 and print the result:
say (+ 2 3)
Note that the + function comes before its operands, not between them. That's because in Fexl, the function you're calling always comes first, followed by any arguments (operands) on which the function operates.
Let's do a little more elaborate math, multiplying the result above by 7:
say (* 7 (+ 2 3))
That will print the result 35.
There's also a little trick you can do where you use a semicolon ";" to avoid extra parentheses. The example above can be written:
say (* 7; + 2 3)
The ";" simply means "treat everything to the right of the semicolon inside this expression as if it were grouped inside a pair of matching parentheses." It doesn't gain you a whole lot in this simple example, but as you will see it can come in very handy and avoid the need for a lot of parentheses off to the right like you see in a language like Lisp.
If you wanted to carry it even further you could even write this, though it might be a little too clever:
say; * 7; + 2 3
Here's how you could define a symbol x for the value, and then print it out:
\x=(* 7 (+ 2 3)) say x
You might want to include a little text with the output to make it more clear:
\x=(* 7 (+ 2 3)) say ["x="x]
The output is:
The notation you see with the brackets "" there is the list notation. A list is any number of values enclosed within matching square brackets. When you call say on a list, it prints all the items in the list, run together. For example this program:
say ["apples" "oranges" "bananas" 1 2 3]
Gives you this output:
In that case you probably wanted those separated with a space, so you could do this:
say (join " " ["apples" "oranges" "bananas" 1 2 3])
And then you'd get:
apples oranges bananas 1 2 3
Now let's define a few symbols and print some output:
\x=(+ 6 5) \y=(* 3 4) \z=(* x y) say ["x="x" y="y" z="z]
The output is:
x=11 y=12 z=132
TODO 20190925: more to come