I prepared a draft for a https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01_ys.html , basically a translation to YS from a Clojure post that is live. The goal is to going to show YS in the best possible way, I'd like to take time for this and I am hereby asking for feedback and improvements on my thus shown YS style.
Ratio support is great! I very much like R *:instead of =>: R* and the possibility to line break.
This a.(b) for a function call is great, had I known that before, but now I am so in awe of my (hence technically unnecessary) workaround of/at that I'd like to keep it in the case of Emmy.
This +/* for partial/compose is horrible 🙂 ! It must never be used in the context of Emmy, math people will run away in droves (after I managed to lure them to YS in the thousands 🙂 )
Concerning ys::std I am generally unsure how to use YS within a Clojure namespace. For Civitas, I do not want to use the graal-compiled parts of YS. I like to add coordinates (via a PR) to deps.edn and require a Clojure namespace containing YS (like I do with [yamlscript.compiler :as ys] in my Emmy example). Is there a standardised way to do this and use ys::std? I have the feeling my use of the git-sha in https://github.com/ClojureCivitas/clojurecivitas.github.io/blob/main/deps.edn is a hack.
ClojureCivitas was started in May 2025 by Timothy Pratley who is very active in the [SciCloj/Clay](https://github.com/scicloj/clay) community. The idea is to leverage Clay, the literate programming tool primarily conceived for data-science, in a platform for conveying any idea to the wider Clojure community. To me, YS is a means to even reach beyond Clojure people with those ideas that merit a respective (?additional?) notebook sporting YS syntax.
ys::std is always referred just like clojure::core is.
graalvm changes nothing
YS also refers most of clojure::string and clojure::math iirc
you don't need to require any of the standard namespaces
and clojure::str is aliased as str as is normal practice.
$ ys -pe ys/compile
#object[ys.ys$compile 0xb4e3111 "ys.ys$compile@b4e3111"]I'll set up a best deps.edn for you later
I'd like to also highlight a Civitas feature: at the bottom of the https://clojurecivitas.github.io/mentat_collective/emmy/fdg_ch01_ys.html#and-the-pudding is a link to the Clojure source code. The YS code is represented as ordinary Clojure strings within the Clojure namespace that represents the notebook.
Hey @markus.agwin! Apologies for just replying. I was in transit to Berlin when you posted and then tested positive for covid when I got here. Been a heck of a week, but I'm on the mend. Taking a look now.
mass * 1/2 * square(v) nice. ratio support recently added!
note
$ ys -pe '1/2'
1/2
$ ys -pe '1 / 2'
0.5because:
$ ys -ce '1 / 2'
(div+ 1 2)The next example could also be:
defn sphere-to-R3(R):
fn([_ [theta phi]]):
up:
R *: sin(theta) * cos(phi)
R *: sin(theta) * sin(phi)
R *: cos(theta)
to avoid the =>s=>: D(0).of(F).at(state) + ( D(1).of(F).at(state) * velocity(state) )
could be:
D(0).of(F).at(state) +: D(1).of(F).at(state) * velocity(state)but also I like to keep my lines short:
D(0).of(F).at(state) +:
D(1).of(F).at(state) *
velocity(state)
You can split lines at many many places in YS
I assume you know that q is in ys::std
Did you know that call is too?
Like many things call is a bit more polymorphic...
$ ys -pe 'call(inc 1)'
2
$ ys -pe 'call("inc" 1)'
2I recently added support for a.(b) to mean a.call(b)
so:
$ ys -pe 'inc.call(41)'
42
$ ys -pe 'inc.(41)'
42$ ys -pe 'reverse("cni").(41)'
42
😄Also + is partial when first arg is ifn?
$ ys -pe 'partial(mul 6): 7'
42
$ ys -pe 'mul + 6: 7'
42and * is compose:
$ ys -pe 'inc * inc: 40'
42
$ ys -pe '(inc * inc).(40)'
42I'll poke at this more later
is https://clojurecivitas.github.io/ a newish thing?