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
;; The Clojure code below is taken from the examples of [this previous post](https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01.html). It is not necessary to understand what the Clojure code does, the purpose is comparison to the infix notation.
63
+
;; The Clojure code below is taken from the snippets of [a previous entry](https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01.html). Please make pull requests to [the source file of this notebook](https://github.com/kloimhardt/clojurecivitas.github.io/blob/infix/src/mentat_collective/emmy/fdg_ch01_ys.clj). 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 critiqued vis-a-vis the proposed infix notation.
64
+
65
+
;; ## First Example
65
66
66
67
(kind/scittle
67
68
'(defn Lfree [mass]
@@ -74,7 +75,9 @@ defn LFree(mass):
74
75
fn([_ _ v]): mass * 1/2 * square(v)
75
76
")
76
77
77
-
;; I proceed to the next infix
78
+
;; ## Another one
79
+
80
+
;; I proceed to the next infix snippet
78
81
79
82
(ys"
80
83
defn sphere-to-R3(R):
@@ -94,11 +97,17 @@ defn sphere-to-R3(R):
94
97
(* R (sin theta) (sin phi))
95
98
(* R (cos theta))))))
96
99
100
+
;; ## Higher order functions
101
+
102
+
;; For the next infix, I introduce `call` (with obvious behaviour) and two aliases.
;; 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
+
111
122
(kind/scittle
112
123
'(defn F->C [F]
113
124
(fn [state]
@@ -117,6 +128,8 @@ defn F-to-C(F):
117
128
(* (((D1) F) state)
118
129
(velocity state)))))))
119
130
131
+
;; ## Another one
132
+
120
133
(ys"
121
134
defn Lsphere(m R):
122
135
compose:
@@ -128,6 +141,10 @@ defn Lsphere(m R):
128
141
'(defn Lsphere [m R]
129
142
(compose (Lfree m) (F->C (sphere->R3 R)))))
130
143
144
+
;; ## The proof is in the pudding
145
+
146
+
;; In order to quote symbols, I introduce a macro called `q`
;; Indeed the results are the same which proves the infix technically works.
166
+
167
+
;; ## Intermission
168
+
169
+
;; The infix notation I use here is `YS` (say "wise"), also called [YAMLScript](https://yamlscript.org/). I have read one opinion that says "I do not want my program to run through a YAML parser". This is a vantage point which is not applicable to Clay notebooks. A Clay notebook is not about maintaining a codebase, it is about conveying ideas and concepts. It is not about the writing of code, it is about the audience which reads the code.
170
+
171
+
;; And concerning reading code, YS has a lot to offer for the Clojure community. Namely that with YS we can communicate the idea of functional+immutable to that particular audience which is not even willing to read code that has the "parens in the wrong place".
172
+
173
+
;; I'd like to put into light a related project of mine. With [LisRoot](https://github.com/kloimhardt/LisRoot) I try to lure away the HEP-community from Python towards Clojure/jank. And here YS is the single best way to show code snippets that are functional+immutable. Those people who like that concept will eventually learn to install a code editor for slurp/barfing and then also cherish the nrepl as we all do.
174
+
175
+
;; I did not find the appropriate YS-compiler on Clojars (for Clay I do not want a dependency on the shared compiled library) , so to deps.edn, I added the following git-sha:
0 commit comments