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",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.9",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@ludus/ludus-js-pure",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.9",
|
||||
"license": "GPL-3.0",
|
||||
"devDependencies": {
|
||||
"shadow-cljs": "^2.26.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ludus/ludus-js-pure",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.9",
|
||||
"description": "A Ludus interpreter in a pure JS function.",
|
||||
"type": "module",
|
||||
"main": "build/ludus.mjs",
|
||||
|
|
|
@ -910,8 +910,8 @@ fn dist {
|
|||
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."
|
||||
() -> base :random ()
|
||||
(n as :number) -> base :random (n)
|
||||
(m as :number, n as :number) -> add (m, random (n))
|
||||
(n as :number) -> mult (n, random ())
|
||||
(m as :number, n as :number) -> add (m, random (sub (n, m)))
|
||||
(l as :list) -> {
|
||||
let i = do l > count > random > floor
|
||||
at (l, i)
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
(set (out :errors) (scanned :errors))
|
||||
(each err (scanned :errors)
|
||||
(e/scan-error err))
|
||||
(break (j/encode out)))
|
||||
(break (-> out j/encode string)))
|
||||
(def parsed (p/parse scanned))
|
||||
(when (any? (parsed :errors))
|
||||
(set (out :errors) (parsed :errors))
|
||||
(each err (parsed :errors)
|
||||
(e/parse-error err))
|
||||
(break (j/encode out)))
|
||||
(break (-> out j/encode string)))
|
||||
(def validated (v/valid parsed ctx))
|
||||
(when (any? (validated :errors))
|
||||
(set (out :errors) (validated :errors))
|
||||
|
@ -43,7 +43,7 @@
|
|||
([err]
|
||||
(e/runtime-error err)
|
||||
(set (out :errors) [err])
|
||||
(break (j/encode out))))
|
||||
(break (-> out j/encode string))))
|
||||
(setdyn :out stdout)
|
||||
(set (out :result) (b/show result))
|
||||
(var post @{})
|
||||
|
@ -51,9 +51,9 @@
|
|||
(set post (i/interpret prelude/post/ast ctx))
|
||||
([err] (e/runtime-error err)))
|
||||
(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