haskell: Phase 10 — Floating stub: pi, exp, log, sin, cos, ** (+6 tests, 37/37)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -440,6 +440,7 @@
|
||||
((= op "div") (floor (/ lv rv)))
|
||||
((= op "rem") (mod lv rv))
|
||||
((= op "quot") (truncate (/ lv rv)))
|
||||
((= op "**") (pow lv rv))
|
||||
((= op ">>=")
|
||||
(if
|
||||
(and (list? lv) (= (first lv) "IO"))
|
||||
@@ -814,6 +815,11 @@
|
||||
env
|
||||
"fromRational"
|
||||
(hk-mk-builtin "fromRational" (fn (x) x) 1))
|
||||
(dict-set! env "pi" 3.14159)
|
||||
(dict-set! env "exp" (hk-mk-builtin "exp" (fn (x) (exp x)) 1))
|
||||
(dict-set! env "log" (hk-mk-builtin "log" (fn (x) (log x)) 1))
|
||||
(dict-set! env "sin" (hk-mk-builtin "sin" (fn (x) (sin x)) 1))
|
||||
(dict-set! env "cos" (hk-mk-builtin "cos" (fn (x) (cos x)) 1))
|
||||
(let
|
||||
((--sx-to-hk-- (fn (lst) (if (empty? lst) (list "[]") (list ":" (first lst) (--sx-to-hk-- (rest lst))))))
|
||||
(--words--
|
||||
|
||||
@@ -165,4 +165,16 @@
|
||||
(hk-deep-force (hk-run "main = fromRational 0.5"))
|
||||
0.5)
|
||||
|
||||
(hk-test "pi ≈ 3.14159" (hk-deep-force (hk-run "main = pi")) 3.14159)
|
||||
|
||||
(hk-test "exp 0 = 1" (hk-deep-force (hk-run "main = exp 0")) 1)
|
||||
|
||||
(hk-test "sin 0 = 0" (hk-deep-force (hk-run "main = sin 0")) 0)
|
||||
|
||||
(hk-test "cos 0 = 1" (hk-deep-force (hk-run "main = cos 0")) 1)
|
||||
|
||||
(hk-test "2 ** 10 = 1024" (hk-deep-force (hk-run "main = 2 ** 10")) 1024)
|
||||
|
||||
(hk-test "log (exp 5) ≈ 5" (hk-deep-force (hk-run "main = log (exp 5)")) 5)
|
||||
|
||||
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}
|
||||
|
||||
Reference in New Issue
Block a user