• 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

Revision7e1613d9838bdb57c0a2349e5e4b7363238a3ecf (tree)
Time2023-02-16 16:12:46
AuthorCorbin <cds@corb...>
CommiterCorbin

Log Message

Add more floating-point operations.

Some NaNs are showing up. I wonder how I should deal with them...

Change Summary

Incremental Difference

--- a/movelist/cammy.scm
+++ b/movelist/cammy.scm
@@ -2,6 +2,8 @@
22 (import scheme
33 matchable)
44
5+ (define (cammy-compile-bin op) (lambda (p) (op (car p) (cdr p))))
6+
57 (define cammy-compile-aux
68 (match-lambda
79 ['id (lambda (x) x)]
@@ -17,15 +19,23 @@
1719 (match-lambda [`(left ,x) (f x)] [`(right ,x) (g x)])]
1820 ['t (lambda (_) #t)] ['f (lambda (_) #f)]
1921 ['not not]
22+ ['conj (lambda (x) (and (car x) (cdr x)))]
23+ ['disj (lambda (x) (or (car x) (cdr x)))]
2024 ['either (lambda (x) (if x '(left *) '(right *)))]
2125 ['zero (lambda (_) 0)]
2226 ['succ (lambda (n) (+ n 1))]
27+ ['n-add (cammy-compile-bin +)]
2328 [`(pr ,f ,g)
2429 (lambda (x)
2530 (let loop ((n x) (acc (f '*)))
2631 (if (= n 0) acc (loop (- n 1) (g acc)))))]
2732 ['f-zero (lambda (_) 0.0)]
2833 ['f-one (lambda (_) 1.0)]
34+ ['f-negate (lambda (f) (- 0.0 f))]
35+ ['f-sin sin] ['f-cos cos]
36+ ['f-add (cammy-compile-bin +)]
37+ ['f-mul (cammy-compile-bin *)]
38+ ['f-lt (cammy-compile-bin <)]
2939 ))
3040
3141 (define (cammy-compile expr)