For YAMLScript releases I have a make bump rule that runs a script to change the version string in dozens of files.
There's a file that defines the files to change and the regexes to be applied, and then a file to do the version bump.
These files were written in Bash:
• https://github.com/yaml/yamlscript/blob/0.1.58/.version.sh
• https://github.com/yaml/yamlscript/blob/0.1.58/util/version-bump
Yesterday I rewrote them in YS:
• https://github.com/yaml/yamlscript/blob/551ec1959905b806f496a298e2cdb0e23295c3f2/.version.ys
• https://github.com/yaml/yamlscript/blob/551ec1959905b806f496a298e2cdb0e23295c3f2/util/version-bump
How can I def a vector in yamlscript? I’m seeing “Sequences (block and flow) not allowed in code mode” when I do row =: [1, 2, 3]
Short answer: row =:: [1, 2, 3]
There are many ways to do this (and most things) in YS. Here's a few:
row =: ! [1, 2, 3]
row =:: [1, 2, 3]
row =::
- 1
- 2
- 3
row =: .[1 2 3]
row =: vec(1 .. 3)I desperately need to finish the basic docs
In YS, every node is either in code mode (where unquoted scalars are ys expressions to be parsed into clojure code) or data mode (where normal YAML semantics take place.
In code mode I decided I really only needed block (indented) mappings and scalars to represent code. So these forms are illegal in code mode (but valid as normal yaml in data mode):
{ foo: bar } # flow mapping
[ foo, bar ] # flow sequence
# block sequence:
- foo
- barIf you see any of those in valid YS then you know its in data mode
now YS support clojure mappings and vector syntax:
say: .[foo bar]
say: .{foo bar}
the leading . is a trick to make the value a string. the . is removed and the rest is parsed as a ys expression (same as clojure here)the single bang tag ! is a mode toggle between code and data modes
it's a bit ugly so :: does the same things for mapping pair values
these are same:
say: ! hello world
say:: hello world
hello world is the string "hello world" because we toggled to data mode.
In code mode it would be 2 symbols.I'll try to get further on the docs this weekend
https://github.com/danielmartincraig/yamlscript-experiments/blob/master/matrix.ys
I want to do a matrix multiplication
Not for speed, just to try out the language