Discuss Scratch
- Discussion Forums
- » Show and Tell
- » StackLisp v0.1.0 documentation
- NFlex23
-
Scratcher
1000+ posts
StackLisp v0.1.0 documentation
This is the documentation for the StackLisp programming language (version 0.1.0 only). Feel free to post questions and programs here as well!
(StackLisp)
version “0.1.0”
—
Documentation & examples
Builtin functions
Operators: +, -, *, /, =, !=, <, >, <=, >=
Example(= (+ (* 2 3) 5) 11)
Booleans: and, or, not
Example(or false (and (not false) true))
Input & output: print, get-input, clear
Example(print (+ "Hello, " (get-input "What is your name? ")))
Special forms
Define: (define name value)
Bind a variable to a value.
Example(define code (get-input "Enter your savecode: "))
If: (if condition true-body false-body)
Run code based on a condition.
Example(if (= (+ 1 2) 3) (print "1 + 2 = 3") (print "!?"))
When: (when condition *body)
Similar to if, but without a false body.
Example(when (= score 10) (define coins (+ coins 1)))
While: (while condition *body)
Execute a block of code until the condition is false.
Example(define i 0) (while (< i 10) (print i) (define i (+ i 1)))
Forever: (forever *body)
Execute a block of code forever.
Example(forever (print "Looping forever!"))
Do: (do *body)
Fit multiple statements in one; useful for if.
Example(define adding true) (if adding (do (print "Adding") (+ 1 1)) (do (print "Subtracting") (- 3 2)))
More coming in version 0.2.0!
- NFlex23
-
Scratcher
1000+ posts
StackLisp v0.1.0 documentation
Documentation for version 2: https://scratch.mit.edu/discuss/topic/599002/
- Discussion Forums
- » Show and Tell
-
» StackLisp v0.1.0 documentation