• 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ónbb980a9488cc1866b3be9f784be7722bcb8f4795 (tree)
Tiempo2021-09-30 07:25:05
AutorCorbin <cds@corb...>
CommiterCorbin

Log Message

Fix up float functions, raytrace a cubic function.

Cambiar Resumen

Diferencia incremental

--- a/frame/frame.ml
+++ b/frame/frame.ml
@@ -4,8 +4,8 @@ module CodeCache = Map.Make (String)
44
55 let primitives =
66 "id comp ignore fst snd pair left right case curry uncurry \
7- zero succ pr nil cons fold t f not conj disj pick \
8- f-zero f-one f-negate f-add f-mul f-sqrt"
7+ zero succ pr nil cons fold t f not conj disj either pick \
8+ f-zero f-one f-negate f-recip f-lt f-add f-mul f-sqrt"
99
1010 let filter =
1111 List.fold_left
--- /dev/null
+++ b/hive/f/10.cammy
@@ -0,0 +1 @@
1+(comp (pair f-one f/9) f-add)
--- /dev/null
+++ b/hive/f/1000.cammy
@@ -0,0 +1 @@
1+(comp f/10 f/cube)
--- /dev/null
+++ b/hive/f/2.cammy
@@ -0,0 +1 @@
1+(comp (pair f-one f-one) f-add)
--- /dev/null
+++ b/hive/f/3.cammy
@@ -0,0 +1 @@
1+(comp (pair f-one f/2) f-add)
--- /dev/null
+++ b/hive/f/9.cammy
@@ -0,0 +1 @@
1+(comp f/3 f/sqr)
--- /dev/null
+++ b/hive/f/approx.cammy
@@ -0,0 +1,2 @@
1+(comp (comp (f/error @0) f/sqr)
2+ (comp (pair id (comp ignore (comp f/1000 f-recip))) f-lt))
--- /dev/null
+++ b/hive/f/cube.cammy
@@ -0,0 +1 @@
1+(comp (comp (pair id fun/dup) (pair fst (comp snd f-mul))) f-mul)
--- /dev/null
+++ b/hive/f/error.cammy
@@ -0,0 +1 @@
1+(comp (pair (comp fst @0) (comp snd f-negate)) f-add)
--- /dev/null
+++ b/hive/nat/cube.cammy
@@ -0,0 +1 @@
1+(comp (comp fun/dup (pair fst (comp snd nat/sqr))) nat/mul)
--- a/movelist/movelist.scm
+++ b/movelist/movelist.scm
@@ -14,6 +14,7 @@
1414 ; Literal s and t.
1515 ((== expr 'conj) (== s (list 'pair '2 '2)) (== t '2))
1616 ((== expr 'disj) (== s (list 'pair '2 '2)) (== t '2))
17+ ((== expr 'either) (== s '2) (== t (list 'sum '1 '1)))
1718 ((== expr 'f-lt) (== s (list 'pair 'F 'F)) (== t '2))
1819 ((== expr 'f-add) (== s (list 'pair 'F 'F)) (== t 'F))
1920 ((== expr 'f-mul) (== s (list 'pair 'F 'F)) (== t 'F))
@@ -27,6 +28,7 @@
2728 ((== expr 'f-zero) (== s '1) (== t 'F))
2829 ((== expr 'f-one) (== s '1) (== t 'F))
2930 ((== expr 'f-negate) (== s 'F) (== t 'F))
31+ ((== expr 'f-recip) (== s 'F) (== t 'F))
3032 ; Literal s, recursive t.
3133 ((fresh (x f) (== expr (list 'pr x f))
3234 (== s 'N) (cammyo x '1 t) (cammyo f t t)))
--- a/stub.scm
+++ b/stub.scm
@@ -26,6 +26,7 @@
2626 (define f (lambda (x) #f))
2727 (define conj (lambda (xy) (and (car xy) (cdr xy))))
2828 (define disj (lambda (xy) (or (car xy) (cdr xy))))
29+(define either (lambda (b) (if b (left '()) (right '()))))
2930 (define pick (lambda (bxy)
3031 (let ((xy (cdr bxy)))
3132 (if (car bxy) (car xy) (cdr xy)))))
@@ -43,6 +44,7 @@
4344 (define f-zero (lambda (x) (flonum 0.0)))
4445 (define f-one (lambda (x) (flonum 1.0)))
4546 (define (f-negate x) (fl- x))
47+(define (f-recip x) (fl/ x))
4648 (define (f-lt xy) (fl<? (car xy) (cdr xy)))
4749 (define (f-add xy) (fl+ (car xy) (cdr xy)))
4850 (define (f-mul xy) (fl* (car xy) (cdr xy)))
@@ -78,6 +80,7 @@
7880 (parser (argv)))
7981
8082 (define ty-parse (match-lambda
83+ ['1 arg-unit]
8184 ['N arg-nat]
8285 ['F arg-fp]
8386 [('list x) (arg-list (ty-parse x))]