• 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

Revision0f8f6b6e68ec2579b9b1a4381812864e9ab6e713 (tree)
Time2023-01-25 02:01:07
AuthorCorbin <cds@corb...>
CommiterCorbin

Log Message

Evaluate images and preimages directly.

I've gotta figure out how to extract the results decently, but this is
amazing in general. The one thing I don't like is that 1 is in the image
of (comp succ succ), which suggests that succ° is broken somehow.

Change Summary

Incremental Difference

--- a/movelist/cammy-repl.scm
+++ b/movelist/cammy-repl.scm
@@ -59,13 +59,22 @@
5959 (define (cammy-image expr)
6060 (time
6161 (display
62- (map
62+ ; (map
6363 ; need the type to display the value properly
64- (lambda (q) (elt->str (car q) (cdr q)))
64+ ; (lambda (q) (elt->str (car q) (cdr q)))
6565 (run 10 (q) (fresh (s t i o)
6666 ; package them up here
6767 (conso t o q)
68- (cammy° expr s t) (eval° expr i o)))))
68+ (cammy° expr s t) (eval° expr i o))))
69+ (newline)))
70+
71+(define (cammy-preimage expr)
72+ (time
73+ (display
74+ (run 10 (q) (fresh (s t i o)
75+ ; package them up here
76+ (conso s i q)
77+ (cammy° expr s t) (eval° expr i o))))
6978 (newline)))
7079
7180 (define (repl!)
@@ -76,6 +85,7 @@
7685 ; command?
7786 ['? (display "help goes here?") (newline) (repl!)]
7887 ['image (cammy-image (read)) (repl!)]
88+ ['preimage (cammy-preimage (read)) (repl!)]
7989 ; read
8090 [expr
8191 (if (eof-object? expr)
--- a/movelist/cammyo.scm
+++ b/movelist/cammyo.scm
@@ -170,11 +170,18 @@
170170 (conde
171171 ((== expr 'id) (== i o))
172172 ((fresh (f g u) (== expr `(comp ,f ,g)) (eval° f i u) (eval° g u o)))
173+ ((== expr 'ignore) (== o 'star))
173174 ((== expr 'fst) (caro i o))
174175 ((== expr 'snd) (cdro i o))
175176 ((== expr 'dup) (conso i i o))
177+ ((== expr 't) (== i 'star) (== o #t))
178+ ((== expr 'f) (== i 'star) (== o #f))
176179 ((== expr 'not) (not° i o))
177180 ((== expr 'zero) (== i 'star) (zeroo o))
178181 ((== expr 'succ) (succ° i o))
182+ ((fresh (f g n) (== expr `(pr ,f ,g))
183+ (conde
184+ ((zeroo i) (eval° f 'star o))
185+ ((succ° n i) (eval° `(comp ,expr ,g) n o)))))
179186 ))
180187 )