@@ -11,12 +11,11 @@ Load `file.yaml` with YAMLScript:
1111!yamlscript/v0/
1212
1313# Get data from external sources:
14- => :
15- names-url = :
16- " https://raw.githubusercontent.com/dominictarr/" +
17- " random-name/master/first-names.json"
14+ names-url = :
15+ " https://raw.githubusercontent.com/dominictarr/\
16+ random-name/master/first-names.json"
1817
19- name-list = : &first-names json/load(curl(names-url))
18+ name-list = : &first-names json/load(curl(names-url))
2019
2120# Data object with literal keys and generated values:
2221name: : rand-nth(*first-names)
@@ -73,15 +72,15 @@ CLI binary `ys` to run:
7372
7473``` text
7574$ ys --compile file.ys
76- (def names-url
77- (+_ "https://raw.githubusercontent.com/dominictarr/"
78- "random-name/master/ first-names. json"))
79- (def name-list (_& 'first-names (json/load (curl names-url))))
80- {"age " (_& 'num (*_ 2 3 7)),
81- "aka" (_-> name-list (list rand-nth)),
82- "color " (_& 'hue (_-> (qw red green blue yellow) (list shuffle) (list first))),
83- "name " (rand-nth (_** ' first-names)),
84- "title" (str (_** 'num) " shades of " (_** 'hue) ".")}
75+ (let
76+ [names-url "https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.json "
77+ name-list (_& ' first-names ( json/load (curl names-url)))]
78+ (%
79+ "name " (rand-nth (_** 'first-names))
80+ "aka" (rand-nth name-list)
81+ "age " (_& 'num (mul+ 2 3 7))
82+ "color " (_& 'hue ( first (shuffle (qw red green blue yellow))))
83+ "title" (str (_** 'num) " shades of " (_** 'hue) ".")))
8584```
8685
8786``` markys:include
0 commit comments