├── .gitignore ├── LICENSE ├── README.md ├── abcs ├── 00-primordia │ ├── array-trait.cant │ ├── list-trait.cant │ ├── map-trait.cant │ ├── miranda-trait.cant │ ├── runtime.cant │ ├── sink-trait.cant │ ├── sugar.cant │ └── types │ │ ├── array.cant │ │ ├── bool.cant │ │ ├── box.cant │ │ ├── cps.cant │ │ ├── ejector.cant │ │ ├── link.cant │ │ ├── map.cant │ │ ├── nil.cant │ │ ├── number.cant │ │ ├── procedure.cant │ │ ├── rune.cant │ │ ├── script.cant │ │ ├── setting.cant │ │ ├── sink.cant │ │ ├── source.cant │ │ ├── symbol.cant │ │ ├── term.cant │ │ ├── text.cant │ │ ├── void.cant │ │ └── zilch.cant ├── 20-cant.cant ├── 21-sequels.cant ├── 30-functions.cant ├── 40-library.cant ├── 50-top.cant └── README.md ├── attic ├── Makefile ├── another-old-compiler-sketch.scm ├── benchmark ├── bob.scm ├── intset.rkt ├── mplus.scm ├── new-kernel.scm ├── new-parse.scm ├── new-self-terp-simplified.rkt ├── new-self-terp.scm ├── new.scm ├── pair.scm ├── search-problem.scm └── stdlib-attic.scm ├── bless-tests ├── cant.scm ├── examples ├── advent-of-code │ ├── 2018 │ │ ├── 01.cant │ │ ├── 02.cant │ │ ├── 03.cant │ │ ├── 04.cant │ │ ├── 05.cant │ │ ├── 06.cant │ │ ├── 07.cant │ │ ├── 08.cant │ │ ├── 09.cant │ │ ├── 10.cant │ │ ├── 11.cant │ │ ├── 12.cant │ │ ├── 13.cant │ │ ├── 14.cant │ │ ├── 15.cant │ │ ├── 16.cant │ │ ├── 17.cant │ │ ├── 18.cant │ │ ├── 19.cant │ │ ├── 20.cant │ │ ├── 21.cant │ │ ├── 22.cant │ │ ├── 23.cant │ │ ├── 24.cant │ │ ├── 25.cant │ │ ├── README.md │ │ ├── data │ │ │ ├── 01.in │ │ │ ├── 02.in │ │ │ ├── 03.in │ │ │ ├── 04.in │ │ │ ├── 05.in │ │ │ ├── 06.in │ │ │ ├── 06.test │ │ │ ├── 07.in │ │ │ ├── 07.test │ │ │ ├── 08.in │ │ │ ├── 08.test │ │ │ ├── 09.in │ │ │ ├── 10.in │ │ │ ├── 10.test │ │ │ ├── 11.in │ │ │ ├── 12.in │ │ │ ├── 12.test │ │ │ ├── 13.in │ │ │ ├── 13.test │ │ │ ├── 13.test1 │ │ │ ├── 13.test2 │ │ │ ├── 14.in │ │ │ ├── 15.combat1 │ │ │ ├── 15.combat2 │ │ │ ├── 15.combat3 │ │ │ ├── 15.combat4 │ │ │ ├── 15.combat5 │ │ │ ├── 15.in │ │ │ ├── 15.movement │ │ │ ├── 15.movement2 │ │ │ ├── 15.test │ │ │ ├── 15.test-movement │ │ │ ├── 16.in │ │ │ ├── 16.test │ │ │ ├── 17.in │ │ │ ├── 17.test │ │ │ ├── 18.in │ │ │ ├── 18.test │ │ │ ├── 19.in │ │ │ ├── 19.test │ │ │ ├── 20.in │ │ │ ├── 21.in │ │ │ ├── 22.in │ │ │ ├── 22.test │ │ │ ├── 23.in │ │ │ ├── 24.in │ │ │ ├── 24.test │ │ │ ├── 25.in │ │ │ ├── 25.test0 │ │ │ ├── 25.test1 │ │ │ ├── 25.test2 │ │ │ ├── 25.test3 │ │ │ └── 25.test4 │ │ ├── elfcode.cant │ │ └── run.cant │ ├── 2019 │ │ ├── 01.cant │ │ ├── 02.cant │ │ ├── 03.cant │ │ ├── 04.cant │ │ ├── 05.cant │ │ ├── 06.cant │ │ ├── data │ │ │ ├── 01.in │ │ │ ├── 02.in │ │ │ ├── 03.in │ │ │ ├── 04.in │ │ │ ├── 05.in │ │ │ └── 06.in │ │ ├── intcode.cant │ │ └── run.cant │ ├── 2020 │ │ ├── 01.cant │ │ ├── 02.cant │ │ ├── 03.cant │ │ ├── 04.cant │ │ ├── 05.cant │ │ ├── 06.cant │ │ ├── 07.cant │ │ ├── 08.cant │ │ ├── 09.cant │ │ ├── 10.cant │ │ ├── 11.cant │ │ ├── 12.cant │ │ ├── 13.cant │ │ ├── 14.cant │ │ ├── 15.cant │ │ ├── 16.cant │ │ ├── 17.cant │ │ ├── 18.cant │ │ ├── 19.cant │ │ ├── 20.cant │ │ ├── data │ │ │ ├── 01.in │ │ │ ├── 02.in │ │ │ ├── 03.in │ │ │ ├── 04.in │ │ │ ├── 05.in │ │ │ ├── 06.in │ │ │ ├── 07.in │ │ │ ├── 08.in │ │ │ ├── 09.in │ │ │ ├── 10.in │ │ │ ├── 11.in │ │ │ ├── 12.in │ │ │ ├── 13.in │ │ │ ├── 14.in │ │ │ ├── 15.in │ │ │ ├── 16.in │ │ │ ├── 17.in │ │ │ ├── 18.in │ │ │ ├── 19.in │ │ │ └── 20.in │ │ └── run.cant │ ├── 2021 │ │ ├── 01.cant │ │ ├── 02.cant │ │ ├── 03.cant │ │ ├── 04.cant │ │ ├── 05.cant │ │ ├── 06.cant │ │ ├── 07.cant │ │ ├── data │ │ │ ├── 01.in │ │ │ ├── 02.in │ │ │ ├── 03.in │ │ │ ├── 04.in │ │ │ ├── 05.in │ │ │ ├── 06.in │ │ │ └── 07.in │ │ ├── run.cant │ │ └── template.cant │ ├── 2023 │ │ ├── 01.cant │ │ ├── 02.cant │ │ ├── 03.cant │ │ ├── 04.cant │ │ ├── 05.cant │ │ ├── 06.cant │ │ ├── 07.cant │ │ ├── 08.cant │ │ ├── 09.cant │ │ ├── 10.cant │ │ ├── data │ │ │ ├── 01.in │ │ │ ├── 02.in │ │ │ ├── 03.in │ │ │ ├── 04.in │ │ │ ├── 05.in │ │ │ ├── 06.in │ │ │ ├── 07.in │ │ │ ├── 08.in │ │ │ └── 09.in │ │ ├── run.cant │ │ └── template.cant │ ├── adventget.py │ └── utils.cant ├── automata │ ├── elementary-ca.cant │ ├── fractran.cant │ ├── game-of-life.cant │ ├── popcode.cant │ ├── slow-life.cant │ ├── text-register-machine.cant │ └── turing-machine.cant ├── beer.cant ├── benchmarks │ ├── dumb-prime-benchmark.cant │ └── sieve.cant ├── brainfuck │ ├── brainfuck.cant │ └── hello.bf ├── cant.cant ├── capability-patterns │ └── revoke.cant ├── code-golf │ ├── README.md │ ├── christmas-trees.cant │ └── squiggly-sequence.cant ├── coding-theory │ ├── hamming-codes.cant │ ├── huffman-coding.cant │ ├── lzw-compression.cant │ └── weighted-code.cant ├── csv.cant ├── cult-of-the-bound-variable.cant ├── dole-editor │ ├── README.md │ ├── buffer.cant │ ├── console.cant │ ├── display.cant │ ├── dole.cant │ ├── editor.cant │ ├── fundamental-mode.cant │ ├── key-map.cant │ ├── keyboard.cant │ └── rune-set.cant ├── exercises-and-puzzles │ ├── cryptarithmetic-brute.cant │ ├── cryptarithmetic-csp.cant │ ├── ghost.cant │ ├── max-path-sum.cant │ ├── max-subsegment-sum.cant │ ├── n-queens.cant │ ├── send-more-money.cant │ ├── sicp1.cant │ └── sicp2.cant ├── failing.cant ├── fizzbuzz.cant ├── forthish-sort-of.cant ├── functional-geometry.cant ├── games │ ├── 2048.cant │ ├── animals.cant │ ├── animals.data │ ├── chess-play.cant │ ├── chess.cant │ ├── connect4.cant │ ├── cryptogram.cant │ ├── glutton │ │ ├── glutton.cant │ │ └── glutton.maze │ ├── hunt-the-wumpus.cant │ ├── lol-robots.cant │ ├── microban │ ├── sat-puzzle │ │ ├── README.md │ │ ├── factoring2.dimacs │ │ ├── factoring6.dimacs │ │ ├── sat-puzzle.cant │ │ ├── subsetsum_random.dimacs │ │ └── trivial.dimacs │ ├── sokoban.cant │ ├── tictactoe.cant │ └── wordles.cant ├── intset1.cant ├── intset2.cant ├── j-bob-proof-checker │ ├── README.md │ ├── prelude.cant │ ├── run-trivi-bob.cant │ ├── runtime.cant │ ├── smoketest.cant │ └── trivi-bob.cant ├── lambda-calculus │ ├── README.md │ ├── compact-lambda.cant │ ├── compiler1.cant │ ├── examples │ │ ├── church.lambda │ │ ├── elementary-ca.lambda │ │ ├── factorial.lambda │ │ ├── reverse.lambda │ │ ├── trivial1.lambda │ │ ├── trivial2.lambda │ │ └── turing-scott.lambda │ ├── interpreter.cant │ ├── lambdacompiler.cant │ ├── lambdaterp.cant │ ├── parser.cant │ └── prelude.cant ├── maze.cant ├── miasma-x86-toolkit │ ├── README.md │ ├── c │ │ └── asm_stuff.h │ ├── code-gen.cant │ ├── parse.cant │ ├── python │ │ └── x86_stub.py │ ├── registers.cant │ └── tables │ │ ├── i386.scm │ │ ├── i387.scm │ │ ├── i486.scm │ │ ├── i586.scm │ │ ├── i586mmx.scm │ │ ├── i686.scm │ │ └── problems.scm ├── nand-circuit-optimizer.cant ├── prefix-to-infix.cant ├── primes.cant ├── project-oiler │ ├── 01.cant │ ├── 02.cant │ ├── 03.cant │ ├── 04.cant │ ├── 05.cant │ ├── 06.cant │ ├── 07.cant │ ├── 08.cant │ ├── 09.cant │ ├── 10.cant │ ├── 11.cant │ ├── 12.cant │ ├── 13.cant │ ├── 14.cant │ ├── 15.cant │ ├── 16.cant │ ├── 17.cant │ ├── 18.cant │ ├── 19.cant │ ├── 20.cant │ ├── 21.cant │ ├── 22.cant │ ├── 23.cant │ ├── 24.cant │ ├── 25.cant │ ├── 26.cant │ ├── 27.cant │ ├── 28.cant │ ├── 29.cant │ ├── 30.cant │ ├── 31.cant │ ├── 32.cant │ ├── 33.cant │ ├── 34.cant │ ├── 35.cant │ ├── 36.cant │ ├── 37.cant │ ├── 38.cant │ ├── 39.cant │ ├── 40.cant │ ├── 41.cant │ ├── 42.cant │ ├── 43.cant │ ├── README.md │ ├── p022_names.comma.txt │ ├── p042_words.comma.txt │ └── utils.cant ├── refactoring │ ├── search-cant-code.cant │ └── search-for-list-pats.cant ├── rosetta-code │ ├── floyd-triangle.cant │ ├── hundred-doors.cant │ └── jewels-and-stones.cant ├── smalltalk72ish-sort-of.cant ├── squickcheck-examples.cant ├── squirm │ ├── README.md │ ├── examples │ │ ├── hello.squirm │ │ ├── mutex.squirm │ │ └── universal_server.squirm │ ├── library │ │ └── foo.cant │ ├── prelude.squirm │ ├── squirm-interpreter.cant │ ├── squirm.cant │ └── test │ │ ├── error-test.squirm │ │ ├── mod-test.squirm │ │ ├── monitor-test.squirm │ │ ├── partner-test.squirm │ │ ├── quasiquote-test.squirm │ │ ├── recur-test.squirm │ │ ├── silly.squirm │ │ ├── smoke-test.squirm │ │ ├── throw-test.squirm │ │ └── timeout-test.squirm ├── terminal │ ├── echo.cant │ └── typing-drill.cant └── text │ ├── anagram-words.cant │ ├── kwic.cant │ ├── markov-text.cant │ ├── most-common.cant │ ├── oodles.cant │ ├── spelling.cant │ └── spelling.train.text ├── guide.md ├── incant ├── library ├── ansi-terminal.cant ├── bag.cant ├── bdd.cant ├── binary-relations.cant ├── bounded-writer.cant ├── calendar.cant ├── cant-source-walker.cant ├── chaos.cant ├── complex.cant ├── csp.cant ├── cycle-write.cant ├── dd.cant ├── debugger.cant ├── english-numbers.cant ├── factoring.cant ├── flexarray.cant ├── flextext.cant ├── format-tables.cant ├── grid-2d.cant ├── memoize.cant ├── minikanren.cant ├── mostly-linear.cant ├── pairing-heap.cant ├── parse.cant ├── parson-core.cant ├── parson.cant ├── polynomials.cant ├── pretty-layout.cant ├── pretty-print.cant ├── queue.cant ├── ratio.cant ├── regex-gen.cant ├── regex-match.cant ├── regex-parse.cant ├── roman.cant ├── sort.cant ├── squickcheck.cant ├── sset.cant ├── sturm.cant ├── text-find.cant ├── text-wrap.cant ├── traceback.cant └── unify.cant ├── player ├── abcs.scm ├── ast.scm ├── elaborate.scm ├── equality.scm ├── macros.scm ├── nonmeta-primitives.scm ├── parse.scm ├── player.scm ├── primordia.scm ├── read.scm ├── setting.scm ├── source.scm ├── thing.scm └── util.scm ├── plug-ins ├── cant-mode.el └── cant.st ├── run-tests ├── system-goals.md ├── t └── test ├── smoke-test.cant ├── test-2048.cant ├── test-bag.cant ├── test-catch.cant ├── test-complex.cant ├── test-continuations.cant ├── test-cycle-write.cant ├── test-dd.cant ├── test-english-numbers.cant ├── test-export-import.cant ├── test-factor.cant ├── test-flexarray.cant ├── test-flextext.cant ├── test-format-tables.cant ├── test-format.cant ├── test-hashmap.cant ├── test-hashset.cant ├── test-huffman-coding.cant ├── test-lambda.cant ├── test-memoize.cant ├── test-metacircular.cant ├── test-module-for-use.cant ├── test-n-queens.cant ├── test-oiler-further.cant ├── test-oiler.cant ├── test-omnibus.cant ├── test-pairing-heap.cant ├── test-parse.cant ├── test-parson-squared.cant ├── test-parson.cant ├── test-pattern-matching.cant ├── test-pretty-print.cant ├── test-quasiquote.cant ├── test-quick.cant ├── test-random.cant ├── test-ratio.cant ├── test-regex-gen.cant ├── test-regex-match-painfully.cant ├── test-regex-match.cant ├── test-roman.cant ├── test-sokoban.cant ├── test-sort.cant ├── test-squirm.cant ├── test-sset.cant ├── test-text-find.cant ├── test-text-wrap.cant ├── test-texts.cant ├── test-unify.cant └── test-use.cant /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.expected 3 | *.out 4 | 5 | benchmark-log 6 | 7 | junk/ 8 | notes/ 9 | old/ 10 | others/ 11 | paip/ 12 | save/ 13 | 14 | # Object files 15 | *.o 16 | *.ko 17 | *.obj 18 | *.elf 19 | 20 | # Precompiled Headers 21 | *.gch 22 | *.pch 23 | 24 | # Libraries 25 | *.lib 26 | *.a 27 | *.la 28 | *.lo 29 | 30 | # Shared objects (inc. Windows DLLs) 31 | *.dll 32 | *.so 33 | *.so.* 34 | *.dylib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | *.i*86 41 | *.x86_64 42 | *.hex 43 | 44 | # Debug files 45 | *.dSYM/ 46 | -------------------------------------------------------------------------------- /abcs/00-primordia/miranda-trait.cant: -------------------------------------------------------------------------------- 1 | ;; The default trait for scripts without an explicit trait. 2 | 3 | (make-trait miranda-trait me 4 | 5 | (to (~ .selfie sink) (sink .display (__depict me))) 6 | 7 | (to message (oops "Match failure" me message))) 8 | -------------------------------------------------------------------------------- /abcs/00-primordia/sink-trait.cant: -------------------------------------------------------------------------------- 1 | (make-trait sink-trait sink 2 | 3 | (to (~ .write a) 4 | (a .selfie sink)) 5 | 6 | ;; TODO include this as a default?: 7 | ;; (to (~ .display a) (sink .write a)) 8 | 9 | ;; TODO .say is a lousy name, but: 10 | ;; - needs to be distinct from text .format, and I haven't 11 | ;; thought of a good other name 12 | ;; - the whole format-text paradigm isn't quite in keeping with 13 | ;; the plain-language style I'm aiming for, so consider this 14 | ;; temporary 15 | (to (~ .say format-text @arguments) 16 | (format .to-sink sink format-text @arguments)) 17 | 18 | (to ~.newline 19 | (sink .display #\newline)) 20 | 21 | (to (~ .print a) ;TODO ugh the name 22 | (sink .write a) 23 | sink.newline) 24 | 25 | (to (~ .displayln a) ;TODO ugh the name 26 | (sink .display a) 27 | sink.newline) 28 | 29 | (to (~ .display-lines lines) ;; To go with source.read-lines 30 | (each! ||(sink .displayln it) lines)) 31 | 32 | (to message 33 | (miranda-trait sink message))) 34 | -------------------------------------------------------------------------------- /abcs/00-primordia/sugar.cant: -------------------------------------------------------------------------------- 1 | ;; Definitions used by desugared code 2 | 3 | (to (as-list seq) ;XXX naming convention for coercions? 4 | (if (list? seq) ;XXX doesn't check the whole list, only the first link 5 | seq 6 | (do copying [seq] 7 | (if seq.none? 8 | '() 9 | (link seq.first (copying seq.rest)))))) 10 | 11 | (to (array<-list xs) 12 | (__array<-list (as-list xs))) 13 | 14 | (to (array<- @elements) 15 | (__array<-list elements)) 16 | 17 | (to (map<- @items) 18 | (map<-items items)) 19 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/array.cant: -------------------------------------------------------------------------------- 1 | (make-trait array-primitive me 2 | 3 | (to ~.none? (= 0 me.count)) ;redundant definition(s) for speed 4 | (to (~ .set! i val) (__vector-set! me i val)) 5 | (to ~.count (__vector-length me)) 6 | (to (~ i) (__vector-ref me i)) 7 | (to (~ .maps? i) (__vector-maps? me i)) 8 | (to (~ .chain v) (__vector-append me v)) 9 | (to ~.values (__vector->list me)) 10 | (to (~ .from i) (__subvector me i me.count)) 11 | (to (~ .from i j) (__subvector me i j)) 12 | 13 | (to (-- (~ .move! dst source lo bound) 14 | message) 15 | ;; Block-copy source[lo..bound) to me[dst..dst+(bound-lo)). 16 | (if (array? source) 17 | (__vector-move! me dst source lo bound) 18 | (array-trait me message))) 19 | 20 | (to ~.copy (__vector-copy me)) 21 | 22 | (to (~ .selfie sink) 23 | (sink .display "[") 24 | (when (< 0 me.count) 25 | (sink .write (me 0)) 26 | (for each! [(x ((__vector->list me) .rest))] 27 | (sink .display #\space) 28 | (sink .write x))) 29 | (sink .display "]")) 30 | 31 | (to ~.first (oops "no .first on array" me)) 32 | (to ~.rest (oops "no .rest on array" me)) 33 | 34 | (to message 35 | (array-trait me message))) ;XXX use trait syntax instead 36 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/bool.cant: -------------------------------------------------------------------------------- 1 | (make-trait bool-primitive me 2 | 3 | (to ~.count (if me 1 0)) 4 | 5 | (to (~ .selfie sink) (sink .display (if me "#yes" "#no"))) 6 | 7 | (to (~ .compare a) 8 | (may a 9 | (be #no (if me '> '=)) 10 | (be #yes (if me '= '<)) 11 | (else #no))) 12 | 13 | ) 14 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/box.cant: -------------------------------------------------------------------------------- 1 | ;; TODO: should a box be a collection? 2 | (make-trait box-primitive me 3 | 4 | (to ~.^ (__box-value me)) 5 | (to (~ .^= value) (__box-value-set! me value)) 6 | 7 | (to (~ .update f) ;TODO better name? I left out the '!' to emphasize it returns the value 8 | (let value (f me.^)) 9 | (me .^= value) 10 | value) ;TODO return void instead? 11 | 12 | (to ~.+1! (me .update ~.+1)) ;; (questionably worth it; name inconsistent with the above note) 13 | (to ~.-1! (me .update ~.-1)) 14 | 15 | (to (~ .+= n) ;; XXX inconsistent in return value wrt ~.+1! 16 | (me .^= (+ me.^ n))) 17 | (to (~ .-= n) 18 | (me .^= (- me.^ n))) 19 | 20 | (to (~ .selfie sink) 21 | (sink .display "")) 24 | 25 | ) 26 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/cps.cant: -------------------------------------------------------------------------------- 1 | ;; A cps-primitive is like a procedure-primitive, but following a 2 | ;; different internal calling convention than the usual Scheme 3 | ;; procedures like __+ and so on. 4 | 5 | ;; There's a magical behavior internal to the player, not expressed in 6 | ;; this script: if the message is a tuple, then handle it with the 7 | ;; Scheme code of this cps-primitive. For all other message types, 8 | ;; use the script below. 9 | 10 | (make-trait cps-primitive me 11 | 12 | (to (~ .selfie sink) 13 | (sink .display "#")) 16 | 17 | ) 18 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/ejector.cant: -------------------------------------------------------------------------------- 1 | (make-trait ejector-primitive me 2 | 3 | (to (~ .eject value) 4 | (__eject me value)) 5 | 6 | (to (~ .selfie sink) 7 | (sink .display "#")) ;TODO show enabledness 8 | 9 | ) 10 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/link.cant: -------------------------------------------------------------------------------- 1 | (make-trait link-primitive me 2 | 3 | (to ~.none? #no) 4 | (to ~.first (__car me)) 5 | (to ~.rest (__cdr me)) 6 | (to ~.count (__length me)) 7 | (to (~ i) (__list-ref me i)) ;XXX just use the trait method? then can e.g. mix lazy and eager list nodes 8 | (to (~ .chain a) (__append me a)) ;TODO fall back to list-trait if a is not a list 9 | 10 | (to (~ .selfie sink) 11 | (may me 12 | (be `(quote ,x) 13 | (sink .display "'") 14 | (sink .write x)) 15 | (else 16 | (sink .display "(") 17 | (sink .write me.first) 18 | (do printing [(r me.rest)] 19 | (hm (when (link? r) 20 | (sink .display " ") 21 | (sink .write r.first) 22 | (printing r.rest)) 23 | (when (null? r)) 24 | (else 25 | (sink .display " . ") ;XXX we're not supporting this in read, iirc 26 | (sink .write r)))) 27 | (sink .display ")")))) 28 | 29 | (to message 30 | (list-trait me message))) ;XXX use trait syntax instead 31 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/map.cant: -------------------------------------------------------------------------------- 1 | ;; Immutable maps, placeholder implementation 2 | ;; N.B. (export foo bar) gets expanded into code like 3 | ;; (map<- (~ 'foo foo) (~ 'bar bar)) 4 | ;; (but hygienic, when I get to fixing the current bad hygiene). 5 | 6 | (make-trait map-primitive map 7 | 8 | (to (~ key) 9 | (may (__mapi-get key map) 10 | (be #no (oops "Missing key" map key)) 11 | (be (~ _ v) v))) 12 | 13 | (to (~ .get key @(optional default)) 14 | (may (__mapi-get key map) 15 | (be #no default) 16 | (be (~ _ v) v))) 17 | 18 | (to (~ .maps? key) 19 | (not (not (__mapi-get key map)))) 20 | 21 | (to ~.none? 22 | (null? (__mapi-items map))) 23 | 24 | (to ~.items 25 | (__mapi-items map)) 26 | 27 | (to (~ .selfie sink) 28 | (sink .display "#")) 33 | 34 | (to message 35 | (map-trait map message))) 36 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/nil.cant: -------------------------------------------------------------------------------- 1 | (make-trait nil-primitive me 2 | 3 | (to ~.none? #yes) 4 | (to ~.first (oops "Empty list" '.first)) 5 | (to ~.rest (oops "Empty list" '.rest)) 6 | (to ~.count 0) 7 | (to (~ i) (oops "Empty list" 'nth i)) 8 | (to (~ .chain a) a) 9 | (to (~ .selfie sink) (sink .display "()")) 10 | 11 | (to message (list-trait me message))) ;XXX use trait syntax instead 12 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/procedure.cant: -------------------------------------------------------------------------------- 1 | ;; An ordinary Scheme procedure like __+ and so on. 2 | 3 | ;; There's a magical behavior internal to the player, not expressed in 4 | ;; this script: if the message is a tuple, then handle it with the 5 | ;; Scheme code of this procedure-primitive. For all other message 6 | ;; types, use the script below (which in practice means to use 7 | ;; miranda-trait). 8 | 9 | (make-trait procedure-primitive me 10 | ) 11 | -------------------------------------------------------------------------------- /abcs/00-primordia/types/script.cant: -------------------------------------------------------------------------------- 1 | (make-trait script-primitive me 2 | 3 | (to ~.name (__script-name me)) 4 | (to ~.trait (__script-trait me)) 5 | (to ~.clauses (__script-clauses me)) 6 | 7 | (to (~ .selfie sink) 8 | (sink .display "