about summary refs log tree commit diff stats
path: root/html/playground
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-09-09 12:07:00 -0400
committerelioat <elioat@tilde.institute>2024-09-09 12:07:00 -0400
commit665ad1f48ddb4513272bfecb372651a4ea96d869 (patch)
tree5cb3917bbecdfa774ae5c2f30462f6167cf76e7a /html/playground
parentf58a7c5aa3f22a318478a636f77d5c7daf644bbc (diff)
downloadtour-665ad1f48ddb4513272bfecb372651a4ea96d869.tar.gz
*
Diffstat (limited to 'html/playground')
-rw-r--r--html/playground/scheme.html123
1 files changed, 6 insertions, 117 deletions
diff --git a/html/playground/scheme.html b/html/playground/scheme.html
index dc6fb55..b8ecd6f 100644
--- a/html/playground/scheme.html
+++ b/html/playground/scheme.html
@@ -83,7 +83,10 @@
 </head>
 <body>
 
-    <div class="playground" id="playground"><div style="display: flex; flex-direction: column; width: 100%;"><textarea placeholder="Scheme here..." style="width: 100%; height: 100px; margin-bottom: 10px; font-family: monospace;"></textarea><button>Evaluate</button><pre style="width: 100%; height: 200px; overflow-y: auto; background-color: rgb(240, 240, 240); padding: 10px; font-family: monospace;"></pre></div></div>
+    <div class="playground" id="playground">    
+        <div class="seesaw" id="seesaw"></div>
+        <div class="slide" id="slide"></div>
+    </div>
 
     <div class="button-container">
         <button onclick="clearEverything()">Clear</button>
@@ -382,122 +385,8 @@ function mountRepl(playground) {
 }
 
 
-mount(mountRepl);
-
-
-
-// Testing 'define' and arithmetic operations
-console.log(evalScheme("(define x 10)")); // Should define 'x' as 10
-console.log(evalScheme("(+ x 5)")); // Should return 15
-console.log(evalScheme("(- x 3)")); // Should return 7
-console.log(evalScheme("(* x 2)")); // Should return 20
-console.log(evalScheme("(/ x 2)")); // Should return 5
-
-// Testing 'eq?' for equality
-console.log(evalScheme("(eq? 1 1)")); // Should return true
-console.log(evalScheme("(eq? 1 2)")); // Should return false
-
-// Testing 'car', 'cdr', 'cons', 'null?'
-console.log(evalScheme("(car (quote (1 2 3)))")); // Should return 1
-console.log(evalScheme("(cdr (quote (1 2 3)))")); // Should return (2 3)
-console.log(evalScheme("(cons 1 (quote (2 3)))")); // Should return (1 2 3)
-console.log(evalScheme("(null? (quote ()))")); // Should return true
-console.log(evalScheme("(null? (quote (1 2 3)))")); // Should return false
-
-// Testing 'zero?' for checking zero
-console.log(evalScheme("(zero? 0)")); // Should return true
-console.log(evalScheme("(zero? 1)")); // Should return false
-
-// Testing 'atom?' for checking if an element is an atom
-console.log(evalScheme("(atom? 1)")); // Should return true
-console.log(evalScheme("(atom? (quote (1 2 3)))")); // Should return false
-
-// Testing 'number?' for checking if an element is a number
-console.log(evalScheme("(number? 42)")); // Should return true
-console.log(evalScheme("(number? (quote hello))")); // Should return false
-
-// Testing 'add1' and 'sub1'
-console.log(evalScheme("(add1 5)")); // Should return 6
-console.log(evalScheme("(sub1 5)")); // Should return 4
-
-// Testing 'quote' for returning unevaluated expressions
-console.log(evalScheme("(quote (1 2 3))")); // Should return (1 2 3)
-
-// Testing 'and' and 'or'
-console.log(evalScheme("(and true true)")); // Should return true
-console.log(evalScheme("(and true false)")); // Should return false
-console.log(evalScheme("(or false false)")); // Should return false
-console.log(evalScheme("(or true false)")); // Should return true
-
-// Testing 'lambda' with a function definition
-console.log(evalScheme("(define add1 (lambda (x) (+ x 1)))")); // Should define add1 function
-console.log(evalScheme("(add1 10)")); // Should return 11
-
-// Testing 'if' for conditional expressions
-console.log(evalScheme("(if (eq? 1 1) (quote yes) (quote no))")); // Should return 'yes
-console.log(evalScheme("(if (eq? 1 2) (quote yes) (quote no))")); // Should return 'no
-
-// Testing 'cond' for multiple conditions
-console.log(evalScheme("(cond ((eq? 1 2) (quote no)) ((eq? 2 2) (quote yes)))")); // Should return 'yes
-console.log(evalScheme("(cond ((eq? 1 2) (quote no)) ((eq? 3 2) (quote nope)))")); // Should return null (no matching condition)
-
-// Testing 'letrec' for recursive bindings
-console.log(evalScheme("(letrec ((factorial (lambda (n) (if (zero? n) 1 (* n (factorial (sub1 n))))))) (factorial 5))"));
-// Should return 120 (5!)</textarea>
-    <div id="console"><div></div><div>15</div><div>7</div><div>20</div><div>5</div><div>true</div><div>false</div><div>{
-  "type": "NumberLiteral",
-  "value": 1
-}</div><div>{
-  "type": "List",
-  "value": [
-    {
-      "type": "NumberLiteral",
-      "value": 2
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 3
-    }
-  ]
-}</div><div>{
-  "type": "List",
-  "value": [
-    1,
-    {
-      "type": "NumberLiteral",
-      "value": 2
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 3
-    }
-  ]
-}</div><div>true</div><div>false</div><div>true</div><div>false</div><div>true</div><div>false</div><div>true</div><div>false</div><div>6</div><div>4</div><div>{
-  "type": "List",
-  "value": [
-    {
-      "type": "NumberLiteral",
-      "value": 1
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 2
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 3
-    }
-  ]
-}</div><div>true</div><div>false</div><div>false</div><div>true</div><div></div><div>11</div><div>{
-  "type": "Symbol",
-  "value": "yes"
-}</div><div>{
-  "type": "Symbol",
-  "value": "no"
-}</div><div>{
-  "type": "Symbol",
-  "value": "yes"
-}</div><div>null</div><div>120</div></div>
+mount(mountRepl);</textarea>
+    <div id="console"></div>
 
     <script>
         function evaluateCode() {