|
|
|
|
|
by asrp
2247 days ago
|
|
It is actually not hard to read (at least in the sense of knowing what something will do when executed; getting the bigger picture takes more practice). The (base) syntax is just whitespace delimited tokens, each representing a function call (or string but we'll come to that later). So foo bar baz
will call the 3 functions in orderfoo()
bar()
baz() All functions are nullary (with side effects; these side effects determine their "true" arity). There aren't really any special characters other than whitespace so 1 1 + print
just translates to 1()
1()
+()
print()
Function names do not have to start with a letter or be alphanumeric. I've happened to name my function so that those ending in a colon treats the next token to the right as a string instead of a function call. The [ function treats everything as strings until ] (that is a single close square bracket as a token) and puts the function in those body in a quote, effectively creating an anonymous function. So[ foo bar baz ] bind: somename defines a function. The equivalent in Python would be def somename():
foo()
bar()
baz()
And you can later call somename in later functions. |
|