ludus-scripts/functions.ld

25 lines
883 B
Plaintext

& Lesson 4: Making functions and naming them
& It's tedious to type out the whole `repeat 4 {...}` scene.
& Let's give this set of commands a name:
fn box! () -> repeat 4 {
forward! (100)
right! (0.25)
}
& fn box! () -> repeat 4 {
& fn `fn` is a special form
& It creates a function.
& box! `box!` is the name of our new function
& Note that it ends with `!`: by convention,
& all commands end with a "bang" like this.
& () `box!` doesn't take arguments.
& This represents an empty list of args.
& -> This arrow is basically punctuation.
& repeat 4 { We already know what this is.
& Run this code. What happens?
& If you want to actually draw a box, what does that look like?