Shen and curried S-expressions

87 views Asked by At

Are functions in Shen uniadic or variadic? Is (+ 1 2 3) in Shen shorthand for (+ 1 (+ 2 3))? I am curious about currying in Shen, and how it works together with S-expressions.

edit After I have played around with the REPL, I believe functions are uniadic. I am impressed by the pattern matching, but can not understand how to write a function that behaves as + if I call it with more than two operands.

1

There are 1 answers

0
Jean-Baptiste On BEST ANSWER

Functions arent variadic, but some macros are.

(0-) (and true true true)
true

(1-) (macroexpand [and true true true])
[and true [and true true]]

(2-) (macroexpand [+ 1 2 3])
[+ 1 [+ 2 3]]

See defmacro for creating new ones:

http://www.shenlanguage.org/learn-shen/macros.html