Compare commits
3 Commits
5e3ffb0e1e
...
533a40bd45
Author | SHA1 | Date | |
---|---|---|---|
|
533a40bd45 | ||
|
1fff319bb6 | ||
|
de647097b7 |
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"shadow-cljs": "^2.26.0",
|
"shadow-cljs": "^2.26.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"description": "A Ludus interpreter in a pure JS function.",
|
"description": "A Ludus interpreter in a pure JS function.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "build/ludus.mjs",
|
"main": "build/ludus.mjs",
|
||||||
|
|
|
@ -910,8 +910,8 @@ fn dist {
|
||||||
fn random {
|
fn random {
|
||||||
"Returns a random number. With zero arguments, returns a random number between 0 (inclusive) and 1 (exclusive). With one argument, returns a random number between 0 and n. With two arguments, returns a random number between m and n. Alternately, given a list, it returns a random member of that list."
|
"Returns a random number. With zero arguments, returns a random number between 0 (inclusive) and 1 (exclusive). With one argument, returns a random number between 0 and n. With two arguments, returns a random number between m and n. Alternately, given a list, it returns a random member of that list."
|
||||||
() -> base :random ()
|
() -> base :random ()
|
||||||
(n as :number) -> base :random (n)
|
(n as :number) -> mult (n, random ())
|
||||||
(m as :number, n as :number) -> add (m, random (n))
|
(m as :number, n as :number) -> add (m, random (sub (n, m)))
|
||||||
(l as :list) -> {
|
(l as :list) -> {
|
||||||
let i = do l > count > random > floor
|
let i = do l > count > random > floor
|
||||||
at (l, i)
|
at (l, i)
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
(set (out :errors) (scanned :errors))
|
(set (out :errors) (scanned :errors))
|
||||||
(each err (scanned :errors)
|
(each err (scanned :errors)
|
||||||
(e/scan-error err))
|
(e/scan-error err))
|
||||||
(break (j/encode out)))
|
(break (-> out j/encode string)))
|
||||||
(def parsed (p/parse scanned))
|
(def parsed (p/parse scanned))
|
||||||
(when (any? (parsed :errors))
|
(when (any? (parsed :errors))
|
||||||
(set (out :errors) (parsed :errors))
|
(set (out :errors) (parsed :errors))
|
||||||
(each err (parsed :errors)
|
(each err (parsed :errors)
|
||||||
(e/parse-error err))
|
(e/parse-error err))
|
||||||
(break (j/encode out)))
|
(break (-> out j/encode string)))
|
||||||
(def validated (v/valid parsed ctx))
|
(def validated (v/valid parsed ctx))
|
||||||
(when (any? (validated :errors))
|
(when (any? (validated :errors))
|
||||||
(set (out :errors) (validated :errors))
|
(set (out :errors) (validated :errors))
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
([err]
|
([err]
|
||||||
(e/runtime-error err)
|
(e/runtime-error err)
|
||||||
(set (out :errors) [err])
|
(set (out :errors) [err])
|
||||||
(break (j/encode out))))
|
(break (-> out j/encode string))))
|
||||||
(setdyn :out stdout)
|
(setdyn :out stdout)
|
||||||
(set (out :result) (b/show result))
|
(set (out :result) (b/show result))
|
||||||
(var post @{})
|
(var post @{})
|
||||||
|
@ -51,9 +51,9 @@
|
||||||
(set post (i/interpret prelude/post/ast ctx))
|
(set post (i/interpret prelude/post/ast ctx))
|
||||||
([err] (e/runtime-error err)))
|
([err] (e/runtime-error err)))
|
||||||
(set (out :draw) (post :draw))
|
(set (out :draw) (post :draw))
|
||||||
(string (j/encode out)))
|
(-> out j/encode string))
|
||||||
|
|
||||||
|
(-> (ludus `
|
||||||
|
random (1, 3)
|
||||||
|
`) j/decode)
|
||||||
|
|
||||||
(ludus `
|
|
||||||
let foo = 42
|
|
||||||
"{foo} bar baz"
|
|
||||||
`)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user