• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A categorical programming language


Commit MetaInfo

Revisiónfc5364cb07370fb5aa5fdc2d03980c4c22d8de1e (tree)
Tiempo2023-02-16 07:44:47
AutorCorbin <cds@corb...>
CommiterCorbin

Log Message

Hammer out the core of an interpreter for CCCs with NNO.

The only thing I don't really like is the encoding of curries, but I'm
willing to trade readability for speed here.

Cambiar Resumen

Diferencia incremental

--- a/movelist/cammy.scm
+++ b/movelist/cammy.scm
@@ -2,10 +2,27 @@
22 (import scheme
33 matchable)
44
5- (define cammy-compile
5+ (define cammy-compile-aux
66 (match-lambda
77 ['id (lambda (x) x)]
8+ [`(comp ,f ,g) (lambda (x) (g (f x)))]
9+ ['ignore (lambda (_) '*)]
10+ [`(pair ,f ,g) (lambda (x) (cons (f x) (g x)))]
11+ [`(curry ,f) (lambda (x) (lambda (y) (f (cons x y))))]
12+ [`(uncurry ,f) (lambda (x) ((f (car x)) (cdr x)))]
13+ ['fst car] ['snd cdr]
14+ ['t (lambda (_) #t)] ['f (lambda (_) #f)]
15+ ['not not]
816 ['zero (lambda (_) 0)]
917 ['succ (lambda (n) (+ n 1))]
18+ [`(pr ,f ,g)
19+ (lambda (x)
20+ (let loop ((n x) (acc (f '*)))
21+ (if (= n 0) acc (loop (- n 1) (g acc)))))]
1022 ))
23+
24+ (define (cammy-compile expr)
25+ (if (list? expr)
26+ (cammy-compile-aux (cons (car expr) (map cammy-compile (cdr expr))))
27+ (cammy-compile-aux expr)))
1128 )