git @ Cat's Eye Technologies Robin / 4ce7018
Add example programs bundle for the JavaScript version. Chris Pressey 3 years ago
1 changed file(s) with 14 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 examplePrograms = [
1 {
2 "contents": "(define a 1)\n(define b 1)\n(assert (equal? (subtract a b) 99))\n",
3 "filename": "assertion.robin"
4 },
5 {
6 "contents": ";''Example of a recursive fexpr. It takes a list of bindings a la `let`\n and returns a snippet of code `bind`ing those values. This is actually\n how `let` is now defined in the stdlib.''\n\n(define expand-let (fexpr (args env)\n (bind body (head (tail args))\n (bind expand-let-r (fexpr (iargs ienv)\n (bind self (eval ienv (head iargs))\n (bind items (eval ienv (head (tail iargs)))\n (if (equal? items ())\n body\n (prepend (literal bind)\n (prepend (head (head items))\n (prepend (head (tail (head items)))\n (prepend (self self (tail items))\n ()))))))))\n (expand-let-r expand-let-r (head args))))))\n\n(display (expand-let ((a 1) (b 2) (c 3)) foo))\n",
7 "filename": "expand-let.robin"
8 },
9 {
10 "contents": ";''Example of a recursive function.''\n\n(define fact (fun (self n)\n (multiply n\n (if (gt? n 1)\n (self self (subtract n 1))\n 1))))\n(display (fact fact 5))\n",
11 "filename": "fact.robin"
12 }
13 ];