Functionally Speaking
YS is a functional programming language.
Therefore we should be able to write functions in YS.
This week I want to do a mini-series of blog posts about using and writing functions in YS.
Let's get started!
Defining Functions🔗
Defining functions in YS is easy.
# File: add.ys
!YS-v0
defn add(a b):
a + b
say: add(ARGS*)
Let's run it:
$ ys add.ys 3 4 5 6 7 8 9
42
Nice!
Return Values🔗
In YS (like other Lisp influenced languages) the last expression in a function is the return value.
You don't use a return
keyword to return a value.
With that said, I'm going to "return" to my Summer afternoon.
I know this was a short post, but, well, the day kind of got away from me.
I'll have a lot more tomorrow.