You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/mentat_collective/emmy/fdg_ch01_ys.clj
+8-13Lines changed: 8 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -59,10 +59,6 @@
59
59
(kind/scittle
60
60
'(def time first))
61
61
62
-
^:kindly/hide-code
63
-
(kind/scittle
64
-
'(def D partial))
65
-
66
62
;; The Clojure code below is taken from a [previous Civitas entry](https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01.html) (the picture from [Emily's parser game](https://ifdb.org/viewgame?id=urxrv27t7qtu52lb)).
67
63
68
64
;; It is not necessary to understand what the Clojure code does. As this semantics does not matter here, it is rather the syntax, the notation, that should be compared and given attention to.
@@ -110,28 +106,27 @@ defn sphere-to-R3(R):
110
106
(defofcall)
111
107
(defatcall))
112
108
113
-
(defDpartial)
114
109
115
110
(ys"
116
111
defn F-to-C(F):
117
112
fn(state):
118
113
up:
119
114
time: state
120
115
F: state
121
-
D(0).of(F).at(state) +:
122
-
D(1).of(F).at(state) *
116
+
partial(0).of(F).at(state) +:
117
+
partial(1).of(F).at(state) *
123
118
velocity(state)
124
119
")
125
120
126
-
;; Again, the above `+:` is normal addition. With `of` and `at` like that, the above `D(0).of(F).at(state)` (which means "take the zeroth derivative of the function F at point state") translates into what are higher order functions in the Clojure version.
121
+
;; Again, the above `+:` is normal addition. With `of` and `at` like that, the above `partial(0).of(F).at(state)` (which means "take the partial derivative with respect to the first variable of the function F at point state") translates into what are higher order functions in the Clojure version.
127
122
128
123
(kind/scittle
129
124
'(defn F->C [F]
130
125
(fn [state]
131
126
(up (time state)
132
127
(F state)
133
-
(+ (((D0) F) state)
134
-
(* (((D1) F) state)
128
+
(+ (((partial0) F) state)
129
+
(* (((partial1) F) state)
135
130
(velocity state)))))))
136
131
137
132
;; ## Another one
@@ -150,7 +145,7 @@ defn Lsphere(m R):
150
145
151
146
;; ## The proof is in the pudding
152
147
153
-
;; Emmy is a symbolic algebra system, `m:q` produces a symbol named `m`.
148
+
;; Emmy is a symbolic algebra system, `s:q` as well as `q: s` produce the symbol named `s`. Below we have `m:q` and `q: t` to produce the symbols `m` and `t`.
154
149
155
150
^:kindly/hide-code
156
151
(defmacroq [s] (list 'quote s))
@@ -159,7 +154,7 @@ defn Lsphere(m R):
159
154
simplify:
160
155
Lsphere(m:q R:q):
161
156
up:
162
-
=>: t:q
157
+
q: t
163
158
up: theta:q phi:q
164
159
up: thetadot:q phidot:q
165
160
")
@@ -255,7 +250,7 @@ L =: Lc(m:q the-metric R2-rect)
0 commit comments