@ksaj @praetor @screwlisp Kap is certainly very high level compared to something like C. It doesn't even expose much in the way of system level access. It's more like Python in that respect, except being faster. 🙂
To briefly explain how to read the tacit expressions, all you really have to understand is how functions combine when there is no argument given to it.
Let's take the function -
as an example. Just like in standard maths, it has two roles: subtraction (when called with two arguments x-y
) or negation (when called with one argument -x
).
All right, so let's take a look at the simplest possible function definition using a tacit expression:
foo ⇐ -
After this, you can type 5 foo 2
to get the result 3. Or foo 11
to get -11.
Let's try a so-called 'train'. A train is just a sequence of functions:
foo ⇐ -×
Let's call it with two arguments to see what happens:
10 foo 4
-40
So, we can see how this actually evaluates as -(10×40)
. This is a general rule when a train is evaluated with two arguments: the right function is called with the two arguments, and then the result is passed to the left function.
Let's call it with one argument:
foo 4
-1
This is the same as -×4
. I.e. call ×4
and then pass the result to -
. The function ×
is extended to support called with one argument, and when it does, it returns the absolute value, i.e. 1. This value is negated by calling -
.
Now, the rest is just an extension of this. There are several special operators, including ∘
, ⍛
and the pair «
and »
which can be used to combine functions in more fancy ways than just using trains as explained above. All of this is documented in the reference: https://kapdemo.dhsdevelopments.com/reference.html#_compositional_operators
I hope this gives a bit of insight into how these functions can be created.
#kap #apl