-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
establish vocabulary for a few more sections
- Loading branch information
Showing
9 changed files
with
123 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env node | ||
|
||
const cos = require('./cosmic'); | ||
|
||
cos.header('MATH', 'show how to execute a sequence of instructions'); | ||
|
||
cos.add(`intro begin`); | ||
cos.add(`define translate:begin:prev $translate`); | ||
cos.add(`define translate | let ((prev $translate:begin:prev)) | ? x | | ||
if (not | function? $x) (prev $x) | | ||
if (not | = (head $x) begin) (prev $x) | | ||
translate | vector (vector ? x (vector last (vector x))) (prepend vector | tail $x)`); | ||
cos.add(`= 4 | begin 1 7 2 4`); | ||
cos.add(`= 6 | begin (set! $demo:make-cell:x 88) (set! $demo:make-cell:x 6) (get! $demo:make-cell:x)`); | ||
cos.add(`= 88 | begin (set! $demo:make-cell:y 88) (set! $demo:make-cell:x 6) (get! $demo:make-cell:y)`); | ||
cos.add(`= 4 | begin (set! $demo:make-cell:x 88) (set! $demo:make-cell:x 6) (get! $demo:make-cell:x) 4`); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
const cos = require('./cosmic'); | ||
|
||
cos.seed(42); | ||
|
||
cos.add(`define graph:make | lambda (x:graph:1 x:graph:2) | pair $x:graph:1 $x:graph:2`); | ||
|
||
cos.add(`define demo:graph | graph:make | ||
(vector 1 2 3 4) | ||
(vector (pair 1 2) (pair 2 3) (pair 1 4))`); | ||
|
||
cos.add(`define exists:graph:2 | lambda (x:graph y:graph:1 z:graph:1) | | ||
exists | ? n | | ||
if (or (< $n 0) (>= $n | list-length | list-ref $x:graph 1)) $false | | ||
list= (list-ref (list-ref $x:graph 1) $n) (pair $y:graph:1 $z:graph:1)`); | ||
|
||
cos.add(`exists:graph:2 $demo:graph 1 2`); | ||
cos.add(`not | exists:graph:2 $demo:graph 1 3`); | ||
cos.add(`not | exists:graph:2 $demo:graph 2 4`); | ||
cos.add(`exists:graph:2 $demo:graph 1 4`); | ||
|
||
cos.add(`define exists:graph:2:list | lambda (x:graph y:graph:1 z:graph:1) | | ||
if (= $y:graph:1 $z:graph:1) $true | | ||
if (exists:graph:2 $x:graph $y:graph:1 $z:graph:1) $true | | ||
exists | ? n:graph:1 | | ||
if (not | exists:graph:2 $x:graph $y:graph:1 $n:graph:1) $false | | ||
exists:graph:2:list $x:graph $n:graph:1 $z:graph:1`); | ||
|
||
cos.add(`exists:graph:2:list $demo:graph 1 2`); | ||
cos.add(`exists:graph:2:list $demo:graph 1 3`); | ||
cos.add(`not | exists:graph:2:list $demo:graph 2 4`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# MATH introduce graph structures | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.