generated from calcit-lang/calcit-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved operations for complex numbers; tag 0.0.1
- Loading branch information
Showing
5 changed files
with
87 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,77 @@ | ||
|
||
{} (:package |app) | ||
:configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!) (:version |0.0.1) | ||
:modules $ [] |calcit-test/ |calcit.std/ | ||
{} (:package |arithmetic) | ||
:configs $ {} (:init-fn |arithmetic.test/main!) (:reload-fn |arithmetic.test/reload!) (:version |0.0.1) | ||
:modules $ [] |calcit-test/ | ||
:entries $ {} | ||
:test $ {} (:init-fn |app.test/main!) (:reload-fn |app.test/reload!) | ||
:modules $ [] |calcit-test/ | ||
:files $ {} | ||
|app.main $ {} | ||
:defs $ {} | ||
|calling-func $ quote | ||
defn calling-func () $ println "\"todo bcc" | ||
|main! $ quote | ||
defn main! () (run-tests) | ||
set-interval 2000 $ fn () (calling-func) | ||
|on-error $ quote | ||
defn on-error (message) (; draw-error-message message) | ||
|reload! $ quote | ||
defn reload! () $ echo "\"Reloaded." | ||
|arithmetic.test $ {} | ||
:ns $ quote | ||
ns app.main $ :require | ||
app.test :refer $ run-tests | ||
calcit.std.time :refer $ set-interval | ||
|app.test $ {} | ||
ns arithmetic.test $ :require | ||
calcit-test.core :refer $ deftest testing is *quit-on-failure? | ||
arithmetic.complex :as complex | ||
:defs $ {} | ||
|main! $ quote | ||
defn main! () $ run-tests | ||
|reload! $ quote | ||
defn reload! () $ println "\"TODO reload" | ||
defn reload! () (run-tests) (println "\"reloaded.") | ||
|run-tests $ quote | ||
defn run-tests () (reset! *quit-on-failure? true) (test-add) | ||
|test-add $ quote | ||
deftest test-add $ testing |add | ||
is $ = 2 (+ 1 1) | ||
:ns $ quote | ||
ns app.test $ :require | ||
calcit-test.core :refer $ deftest testing is *quit-on-failure? | ||
defn run-tests () (reset! *quit-on-failure? true) (test-basic) | ||
|test-basic $ quote | ||
deftest test-basic | ||
testing |add $ is | ||
= ([] 3 5) | ||
complex/&+ ([] 1 2) ([] 2 3) | ||
testing |minus $ is | ||
= ([] -1 -1) | ||
complex/&- ([] 1 2) ([] 2 3) | ||
|arithmetic.complex $ {} | ||
:ns $ quote (ns phlox.complex) | ||
:defs $ {} | ||
|&* $ quote | ||
defn &* (v1 v2) | ||
let-sugar | ||
[] a b | ||
, v1 | ||
([] x y) v2 | ||
[] | ||
- (* a x) (* b y) | ||
+ (* a y) (* b x) | ||
|&+ $ quote | ||
defn &+ (p1 p2) | ||
let-sugar | ||
[] a b | ||
, p1 | ||
([] x y) p2 | ||
[] (+ a x) (+ b y) | ||
|&- $ quote | ||
defn &- (v1 v2) | ||
let-sugar | ||
[] a b | ||
, v1 | ||
([] x y) v2 | ||
[] (- a x) (- b y) | ||
|&/ $ quote | ||
defn rebase (value base) "\"complex number division, renamed since naming collision" $ let-sugar | ||
[] x y | ||
, value | ||
([] a b) base | ||
inverted $ / 1 | ||
+ (* a a) (* b b) | ||
[] | ||
* inverted $ + (* x a) (* y b) | ||
* inverted $ - (* y a) (* x b) | ||
|conjugate $ quote | ||
defn conjugate (pair) (update pair 1 negate) | ||
|divide-by $ quote | ||
defn divide-by (point x) | ||
[] | ||
/ (first point) x | ||
/ (last point) x | ||
|polar-point $ quote | ||
defn polar-point (angle r) | ||
[] | ||
* r $ js/Math.cos angle | ||
* r $ js/Math.sin angle | ||
|scale $ quote | ||
defn scale (pair v) | ||
map pair $ fn (x) (* v x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { main_$x_, reload_$x_ } from "./js-out/app.test.mjs" | ||
import { main_$x_, reload_$x_ } from "./js-out/arithmetic.test.mjs" | ||
|
||
main_$x_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "0.0.7", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"@calcit/procs": "^0.5.41" | ||
}, | ||
|