Compare commits
No commits in common. "533a40bd45a4759c25ef4de28f12203819e623b0" and "5e3ffb0e1e1d33d238697adf7c7f840785313a75" have entirely different histories.
533a40bd45
...
5e3ffb0e1e
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.9",
|
"version": "0.1.8",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.9",
|
"version": "0.1.8",
|
||||||
"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.9",
|
"version": "0.1.8",
|
||||||
"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) -> mult (n, random ())
|
(n as :number) -> base :random (n)
|
||||||
(m as :number, n as :number) -> add (m, random (sub (n, m)))
|
(m as :number, n as :number) -> add (m, random (n))
|
||||||
(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 (-> out j/encode string)))
|
(break (j/encode out)))
|
||||||
(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 (-> out j/encode string)))
|
(break (j/encode out)))
|
||||||
(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 (-> out j/encode string))))
|
(break (j/encode out))))
|
||||||
(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))
|
||||||
(-> out j/encode string))
|
(string (j/encode out)))
|
||||||
|
|
||||||
(-> (ludus `
|
|
||||||
random (1, 3)
|
|
||||||
`) j/decode)
|
|
||||||
|
|
||||||
|
(ludus `
|
||||||
|
let foo = 42
|
||||||
|
"{foo} bar baz"
|
||||||
|
`)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user