This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-16
Channels
- # announcements (22)
- # beginners (4)
- # biff (4)
- # cider (5)
- # clerk (3)
- # clojure (28)
- # clojure-chennai (1)
- # clojure-europe (23)
- # clojure-gamedev (7)
- # clojure-korea (5)
- # clojure-madison (3)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (49)
- # clojure-sweden (7)
- # clojure-uk (4)
- # clojuredesign-podcast (14)
- # clojurescript (10)
- # clr (5)
- # cursive (4)
- # datascript (17)
- # datomic (2)
- # events (1)
- # garden (1)
- # introduce-yourself (2)
- # jobs-discuss (14)
- # lsp (23)
- # malli (14)
- # missionary (9)
- # off-topic (109)
- # overtone (7)
- # polylith (5)
- # releases (5)
- # shadow-cljs (7)
- # sql (13)
- # testing (30)
- # xtdb (10)
- # yamlscript (44)
I did this matrix multiplication toy implementation based on some code that @sritchie09 put on stack overflow years ago, and it’s got me thinking that yamlscript is just as approachable as Python https://github.com/danielmartincraig/yamlscript-experiments/blob/master/matrix.ys
Very nice:
$ curl -s | time ys -
((3 2 1) (6 5 4) (9 8 7))
0.00user 0.03system 0:00.08elapsed 42%CPU (0avgtext+0avgdata 48000maxresident)k
0inputs+0outputs (0major+4746minor)pagefaults 0swaps
🙂Sorry I missed this earlier.
How do I get all messages in #C05HQFMTURF to notify me?
I just get notifications for mentions and threads I'm active in...
click on the channel name to get settings, then change the dropdown here
Sweet! Thanks @sritchie09!
What’s the syntax for an anonymous function in yamlscript? Apologies if you already explained to me
$ ys -e 'foo =: \(%1 * %2)' -e 'foo: 6 7' -c
(def foo (fn [& [_1 _2]] (*_ _1 _2)))
(foo 6 7)
$ ys -e 'foo =: \(%1 * %2)' -e 'foo: 6 7' -p
42
Note that you can't use %
, you need to use %1
%
is the rem
operator in YS:
$ ys -e 'say: 42 % 13'
3
(also %%
is the mod
operator)
Of course you can always use fn
(as in clojure)
$ ys -e 'foo =: (fn [a b] (a * b))' -e 'foo: 6 7' -p
42
with less parens:
$ cat x.ys
!yamlscript/v0
foo =:
fn [a b]: a * b
say:
foo: 6 7
$ ys x.ys
42
You're awake!
Ha yes I am!
This is great help
I'll review your matrix code more closely now
It looked pretty good when I glanced at it
I did a bunch of things different to show off various ways to do things
My way is not the correct way, just an alternate way
The one thing that YS won't do for you is offer a single syntax, like a Lisp does. I know some people like this because it keeps that part of the language simple. YS lets you do stuff in lots of ways. Some are close to Lisp and some avoid all parens, and some are in between. But if you ok with that, YS can offer you some really cool syntactic things.
One thing I struggle with constantly is remembering argument order for things like take
and nth
and pretty much anything that takes multiple args
This is great, I’m intrigued by moving the :
to the places where you moved it
get-some-seq().take(5)
used to blow up because the seq gets inserted first.
One solution is get-some-seq().take(5 _)
which works but angered me.
apply map vector: m
is different than I was expecting, I think I thought the :
always had to follow the first thing in the expression
So I made I made:
$ ys -ce 'get-some-seq().take(5)'
(__ (get-some-seq) (list +take 5))
and +take
checks it's args and DTRT. slower but cleaner and no need to remember.
If speed counts then:
$ ys -ce 'get-some-seq().take(5 _)'
(__ (get-some-seq) (list take 5 '_))
is still available$ ys -ce '
a: b c d
a b: c d
a b c: d
a b c d:'
(a b c d)
(a b c d)
(a b c d)
(a b c d)
😄if:
(a > b)
bar
baz
works fine, but I'd rather see:
if (a > b):
bar
baz
but you can
if (a > b) bar: baz
if that's your thing 🙂We don't support:
$ ys -ce ': a b c d'
Error: while parsing a block mapping
in reader, line 2, column 1:
: a b c d
^
That's SnakeYAML-Engine's fault not mine.
It's actually valid YAML according to the 1.2 spec:
https://play.yaml.io/main/parser?input=OiBhIGIgYyBkBut we are talking about making it invalid
Haha oh my gosh so the :
can be anywhere that makes sense to the author almost
That's spot on
That reminds me, today I got a replacement for SnakeYAML working. RapidYAML (world's fastest known YAML parser in C++)
Ooh nice
in the next release you can enable it with export YS_PARSER=rapidyaml
It comes as a shared library with a JNA wrapper. Still working on the cleanest install strategy.