diff options
Diffstat (limited to 'doc.txt')
-rw-r--r-- | doc.txt | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -6,7 +6,7 @@ func: badthing function arr: [ 10 20 30 ] array of badthing values array indexing is the same as function calling: (a 1) -> 20 - string: "hii". + string: 'word "string with spaces" strings are interned: two strings with the same contents are always the same object in memory @@ -21,34 +21,44 @@ # builtin forms arithmetic: + - * / % (+ 1 2) - equality: (= (+ 2 2) 4) comparison: (< 0 1). ">" omitted deliberately. + equality: (= (+ 2 2) 4) + arrlit: internal; [1 2 3] is technically sugar for (arrlit (1 2 3)) + def: (def foo 123) creates new local in current scope + defn: (defn (f x) body...) function's name bound as local within body + do: (do body...) returns value of last expr in body + each: (each (x arr) body...) array for-each loop. returns nil + fn: (fn (arg0 arg1 arg2) body...) anonymous. for now. + for: (for (i 10) body...) numeric for loop, i=0,1,...,9 returns nil + if: (if cond true-expr false-expr) let: unremarkable. (let (a 100 b 200) (+ a b)) + quote: internal. 'foo and "foo" are technically sugar for (quote foo) set!: mutates values. (set! x 10) arrays: (set! (a 1) 20) sets index 1 of a setting 1 past the end of an array will append - if: (if cond true-expr false-expr) + when: (when cond body...) like if with multiple body exprs. returns nil while: (while cond body...) returns nil - for: (for (i 10) body...) numeric for loop, i=0,1,...,9 returns nil - each: (each (x arr) body...) array for-each loop. returns nil - do: (do body...) returns value of last expr in body - def: (def foo 123) creates new local in current scope - fn: (fn (arg0 arg1 arg2) body...) anonymous. for now. - defn: (defn (f x) body...) function's name bound as local within body # builtin functions (clock): clock(3) (say x): print representation of x, followed by newline (write x): print representation of x, with no newline (writebytes a): a is a list of nums in [0,255] + (readstring filename): reads whole file as a string (arr): create new empty array (append! a x): appends to array a in place, returns a + (delete! a i): deletes element i of array a. i must be in bounds. returns a (# a): get length of array a (, ...): pend. concatenates arrays, promotes non-arrays to arrays (, [1 2 3] 4) -> [1 2 3 4] (, [1 2 3] [4 5]) -> [1 2 3 4 5] (, 10 20) -> [10 20] etc (s, ...): spend. concatenates strings + (s,@ a): spendsplat. (s,@ [a b c]) <=> (s, a b c) + (ssub? needle haystack): is substring? + (ssplit delim text): splits text on delim, delim is removed from sections + (schars-ascii s): returns arr containing ascii chars (bytes) in s + (sin x) (cos x) (ceil x) (floor x) (abs x): should be obvious # cmdline args bth [-Dl] [-Dt] filenames... |