plainscript-lang 1.0.361 → 1.0.363

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +383 -55
  2. package/compiler/bundler.js +78 -3
  3. package/compiler/cli.js +224 -30
  4. package/compiler/formatter.js +21 -1
  5. package/compiler/generator.js +490 -114
  6. package/compiler/ir.js +61 -0
  7. package/compiler/lexer.js +42 -7
  8. package/compiler/lsp.js +234 -0
  9. package/compiler/parser.js +780 -110
  10. package/compiler/type-checker.js +246 -0
  11. package/compiler/version.js +1 -1
  12. package/docs/CAPABILITY_GAP_AUDIT.md +19 -3
  13. package/docs/GAME-PROMPT.md +3 -3
  14. package/docs/PLAINSCRIPT-GRAMMAR.md +308 -0
  15. package/docs/PLAINSCRIPT-SPEC.md +231 -5
  16. package/docs/index.html +5 -5
  17. package/docs/website/script.js +1 -1
  18. package/examples/ai-memory-cli.pln +221 -0
  19. package/examples/ai-memory.json +1 -0
  20. package/examples/ai-providers.pln +1 -1
  21. package/examples/arrays.pln +1 -1
  22. package/examples/async-errors.pln +1 -1
  23. package/examples/auth-api.pln +1 -1
  24. package/examples/auth-sessions.pln +1 -1
  25. package/examples/basics.pln +1 -1
  26. package/examples/bots.pln +1 -1
  27. package/examples/browser-interactive/README.md +1 -1
  28. package/examples/browser-interactive/src/interactive.pln +1 -1
  29. package/examples/cache-and-jobs.pln +1 -1
  30. package/examples/cache-schedule.pln +1 -1
  31. package/examples/canvas-game/README.md +1 -1
  32. package/examples/canvas-game/src/game.pln +1 -1
  33. package/examples/collections.pln +1 -1
  34. package/examples/compound-assignments.pln +24 -0
  35. package/examples/concurrency.pln +2 -2
  36. package/examples/conditions.pln +1 -1
  37. package/examples/database.pln +1 -1
  38. package/examples/day2.pln +1 -1
  39. package/examples/day3.pln +1 -1
  40. package/examples/deployment.pln +1 -1
  41. package/examples/email-send.pln +1 -1
  42. package/examples/error-handling.pln +1 -1
  43. package/examples/expressions.pln +1 -1
  44. package/examples/file-manager-cli.pln +51 -0
  45. package/examples/file-uploads.pln +1 -1
  46. package/examples/files-and-config.pln +1 -1
  47. package/examples/files.pln +1 -1
  48. package/examples/football-backend/app.pln +1 -1
  49. package/examples/functions.pln +1 -1
  50. package/examples/hello.pln +1 -1
  51. package/examples/http-client.pln +1 -1
  52. package/examples/http.pln +1 -1
  53. package/examples/id-verification/app.pln +1 -1
  54. package/examples/interactive-cli.pln +34 -0
  55. package/examples/javascript-library/README.md +1 -1
  56. package/examples/javascript-library/src/interop.pln +1 -1
  57. package/examples/json.pln +1 -1
  58. package/examples/loops.pln +1 -1
  59. package/examples/memoize-demo.pln +31 -0
  60. package/examples/modules/app.pln +1 -1
  61. package/examples/modules/main.pln +1 -1
  62. package/examples/modules/math.pln +1 -1
  63. package/examples/mongo.pln +1 -1
  64. package/examples/normalization-forms.pln +22 -0
  65. package/examples/objects.pln +1 -1
  66. package/examples/ocr.pln +1 -1
  67. package/examples/packages.pln +1 -1
  68. package/examples/random-cli.pln +32 -0
  69. package/examples/record-kinds.pln +1 -1
  70. package/examples/records.pln +1 -1
  71. package/examples/rest-api-fetch.pln +1 -1
  72. package/examples/rest-api.pln +1 -1
  73. package/examples/run-in-parallel.pln +25 -0
  74. package/examples/scheduled-tasks.pln +1 -1
  75. package/examples/search-and-filter.pln +1 -1
  76. package/examples/server.pln +1 -1
  77. package/examples/sessions-and-cookies.pln +1 -1
  78. package/examples/sqlite.pln +1 -1
  79. package/examples/start.pln +1 -1
  80. package/examples/stats-cli.pln +29 -0
  81. package/examples/stdlib.pln +1 -1
  82. package/examples/string-helpers.pln +23 -0
  83. package/examples/string-verbs.pln +1 -1
  84. package/examples/telegram-ai-bot.pln +1 -1
  85. package/examples/telegram-bot.pln +1 -1
  86. package/examples/terminal-cli.pln +11 -0
  87. package/examples/testing.pln +1 -1
  88. package/examples/three-dimensional/README.md +1 -1
  89. package/examples/three-dimensional/src/scene.pln +1 -1
  90. package/examples/todo-cli.pln +98 -0
  91. package/examples/web-api.pln +1 -1
  92. package/examples/web-app.pln +1 -1
  93. package/examples/websocket-server.pln +1 -1
  94. package/examples/websocket.pln +1 -1
  95. package/examples/whatsapp-bot/pairing.pln +1 -1
  96. package/examples/whatsapp-bot/qr.pln +1 -1
  97. package/package.json +16 -6
@@ -0,0 +1,24 @@
1
+ // PlainScript 1.0.363 — compound arithmetic assignments.
2
+ // The symbols `+= -= *= /= %=` map to the same assignment machinery as the
3
+ // word forms; the legacy `++=` spelling is still accepted as `+=`.
4
+
5
+ let score be 10
6
+ score += 5 // 15
7
+ score -= 3 // 12
8
+ score *= 2 // 24
9
+ score /= 4 // 6
10
+ score %= 7 // 6 (remainder of 6 / 7)
11
+ show "score is " + score
12
+
13
+ let word be "ver"
14
+ word += "nacular"
15
+ show word
16
+
17
+ let counter be 0
18
+ counter ++= 1
19
+ counter ++= 1
20
+ counter ++= 1
21
+ show "legacy ++= count is " + counter
22
+
23
+ let items be list with "a", "b"
24
+ show count of items
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: parallel operations and timeouts.
1
+ // PlainScript 1.0.363: parallel operations and timeouts.
2
2
 
3
3
  make firstJob()
4
4
  wait for sleep(10)
@@ -10,7 +10,7 @@ make secondJob()
10
10
  give "second"
11
11
  done
12
12
 
13
- remember results as allOf(list with firstJob(), secondJob())
13
+ remember results as all of [firstJob(), secondJob()]
14
14
  show results
15
15
 
16
16
  remember quick as withTimeout(firstJob(), 1000)
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: conditions and string predicates.
1
+ // PlainScript 1.0.363: conditions and string predicates.
2
2
 
3
3
  remember score as 87
4
4
  remember label as "PlainScript"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: SQLite database.
1
+ // PlainScript 1.0.363: SQLite database.
2
2
  database "app.db" using "wasm"
3
3
  execute
4
4
  CREATE TABLE IF NOT EXISTS notes (body TEXT)
package/examples/day2.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: conditional blocks.
1
+ // PlainScript 1.0.363: conditional blocks.
2
2
  remember age as 21
3
3
  if age is at least 18
4
4
  show "adult"
package/examples/day3.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: functions.
1
+ // PlainScript 1.0.363: functions.
2
2
  make greet(name)
3
3
  give `Hello, ${name}!`
4
4
  done
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: production-shaped web entry point.
1
+ // PlainScript 1.0.363: production-shaped web entry point.
2
2
  web app
3
3
  route get "/health"
4
4
  reply "ok"
@@ -1,3 +1,3 @@
1
- // PlainScript 1.0.361: email application placeholder.
1
+ // PlainScript 1.0.363: email application placeholder.
2
2
  remember recipient as "team@example.com"
3
3
  show `mail queued for ${recipient}`
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: recovery and cleanup.
1
+ // PlainScript 1.0.363: recovery and cleanup.
2
2
  try
3
3
  show "work"
4
4
  recover as error
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: expression operators.
1
+ // PlainScript 1.0.363: expression operators.
2
2
  remember sumValue as (2 + 3) * 4
3
3
  if sumValue is 20
4
4
  show "exact"
@@ -0,0 +1,51 @@
1
+ // PlainScript 1.0.363 — a small file manager CLI.
2
+ // Usage:
3
+ // plainscript run examples/file-manager-cli.pln list
4
+ // plainscript run examples/file-manager-cli.pln copy readme.md readme-backup.md
5
+ // plainscript run examples/file-manager-cli.pln remove readme-backup.md
6
+ // plainscript run examples/file-manager-cli.pln archive old-logs
7
+
8
+ make showHelp()
9
+ show "file-manager-cli.pln <list|copy|remove|archive> <path...>"
10
+ done
11
+
12
+ make main()
13
+ remember argv as args()
14
+ if count of argv is 0
15
+ showHelp()
16
+ exit(0)
17
+ done
18
+ remember command as argv at position 0
19
+ if command is "list"
20
+ show listFolder(".")
21
+ otherwise if command is "copy"
22
+ if count of argv is at least 3
23
+ copyFile(argv at position 1, argv at position 2)
24
+ show "copied " + argv at position 1 + " to " + argv at position 2
25
+ otherwise
26
+ show "usage: ... copy <from> <to>"
27
+ done
28
+ otherwise if command is "remove"
29
+ if count of argv is at least 2
30
+ deleteFile(argv at position 1)
31
+ show "removed " + argv at position 1
32
+ otherwise
33
+ show "usage: ... remove <file>"
34
+ done
35
+ otherwise if command is "archive"
36
+ if count of argv is at least 2
37
+ archiveEntry(argv at position 1)
38
+ otherwise
39
+ show "usage: ... archive <path>"
40
+ done
41
+ otherwise
42
+ showHelp()
43
+ done
44
+ done
45
+
46
+ make archiveEntry(path)
47
+ moveFile(path, path + "-archive")
48
+ show "archived " + path + " as " + path + "-archive"
49
+ done
50
+
51
+ main()
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: upload route.
1
+ // PlainScript 1.0.363: upload route.
2
2
  web app
3
3
  accept uploads limit "5 MB" allow list with "image/png" folder "uploads"
4
4
  route post "/upload"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: files and environment configuration.
1
+ // PlainScript 1.0.363: files and environment configuration.
2
2
  remember filename as env("CONFIG_FILE")
3
3
  if filename is null
4
4
  remember filename as "config.json"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: file and path operations.
1
+ // PlainScript 1.0.363: file and path operations.
2
2
 
3
3
  remember report as readFile("README.md")
4
4
  show length(report)
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: a complete authenticated SQLite API.
1
+ // PlainScript 1.0.363: a complete authenticated SQLite API.
2
2
 
3
3
  web app
4
4
  database ":memory:" using "wasm"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: functions, defaults, and returns.
1
+ // PlainScript 1.0.363: functions, defaults, and returns.
2
2
 
3
3
  make greet(name)
4
4
  give `Hello, ${name}!`
@@ -1,2 +1,2 @@
1
- // PlainScript 1.0.361: hello world.
1
+ // PlainScript 1.0.363: hello world.
2
2
  show "Hello, PlainScript!"
@@ -1,3 +1,3 @@
1
- // PlainScript 1.0.361: HTTP client request.
1
+ // PlainScript 1.0.363: HTTP client request.
2
2
  remember response as get "https://example.com" timeout 5000
3
3
  show response.status
package/examples/http.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: HTTP client requests.
1
+ // PlainScript 1.0.363: HTTP client requests.
2
2
 
3
3
  remember response as get "https://example.com/api/items" timeout 5000
4
4
  if response.ok is true
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: upload and OCR verification service.
1
+ // PlainScript 1.0.363: upload and OCR verification service.
2
2
 
3
3
  web app
4
4
  accept uploads limit "5 MB" allow list with "image/png", "image/jpeg" folder "uploads"
@@ -0,0 +1,34 @@
1
+ // PlainScript 1.0.363 — an interactive terminal menu.
2
+ // Usage: plainscript run examples/interactive-cli.pln
3
+ // Runs a loop of `ask`, `confirm`, and `choose` prompts. When given the
4
+ // non-interactive flag it self-drives with seeded answers (for tests).
5
+
6
+ make playOnce(seedMode)
7
+ if seedMode is true
8
+ show "seeded: " + choose("Pick a color", ["red", "green", "blue"])
9
+ otherwise
10
+ ask "What is your name? " as guest
11
+ show "hello, " + guest
12
+ remember ok as confirm("Shall we continue")
13
+ if ok is true
14
+ show "choice: " + choose("Drink?", ["tea", "coffee", "juice"])
15
+ otherwise
16
+ show "ok, maybe next time"
17
+ done
18
+ done
19
+ done
20
+
21
+ make main()
22
+ remember argv as args()
23
+ if count of argv is at least 1 and argv at position 0 is "seeded"
24
+ playOnce(true)
25
+ otherwise
26
+ if count of argv is at least 1
27
+ show "usage: ... [seeded]"
28
+ exit(1)
29
+ done
30
+ playOnce(false)
31
+ done
32
+ done
33
+
34
+ main()
@@ -11,7 +11,7 @@ What the script exercises:
11
11
  - `bring THREE from "three"` emits `require('three')` at the top of the build.
12
12
  - `new THREE.Scene()`, `new THREE.WebGLRenderer()`, `new THREE.SphereGeometry(...)`
13
13
  and `new THREE.Mesh(geo, mat)` fill a starfield of 150 primitives. Colors use
14
- v1.0.361 hex literals (`0x40c463`), so the palette is legible at a glance.
14
+ v1.0.363 hex literals (`0x40c463`), so the palette is legible at a glance.
15
15
  - A resize callback `make fitWindow() ... done` passed straight to
16
16
  `window.addEventListener("resize", fitWindow)`.
17
17
  - `fetchJson("config.json")` (auto-awaiting) reads `{stars, color}` out of a
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: drop into an npm library via import, callbacks, and fetch.
1
+ // PlainScript 1.0.363: drop into an npm library via import, callbacks, and fetch.
2
2
 
3
3
  bring THREE from "three"
4
4
 
package/examples/json.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: JSON values and transformations.
1
+ // PlainScript 1.0.363: JSON values and transformations.
2
2
 
3
3
  remember person as record with name "Ada" and role "engineer" done
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: collection and numeric loops.
1
+ // PlainScript 1.0.363: collection and numeric loops.
2
2
 
3
3
  remember colors as list with "red", "green", "blue"
4
4
 
@@ -0,0 +1,31 @@
1
+ // PlainScript 1.0.363 — memoization and the new statistics/vector primitives.
2
+
3
+ make slowSquare(n)
4
+ give n * n
5
+ done
6
+
7
+ remember fastSquare as memoize(slowSquare)
8
+ show fastSquare(9)
9
+ show fastSquare(9)
10
+
11
+ // A memoized recursive function still uses `make` + `yield`-free bodies:
12
+ make expensiveSum(n)
13
+ if n is at most 0
14
+ give 0
15
+ done
16
+ give n + expensiveSum(n - 1)
17
+ done
18
+ show expensiveSum(10)
19
+
20
+ // Vector primitives.
21
+ remember a as [1, 2, 3]
22
+ remember b as [4, 5, 6]
23
+ show "dot: " + dotProduct(a, b)
24
+ show "length of a: " + magnitude(a)
25
+ show "unit of a: " + join(normalize(a), ", ")
26
+
27
+ remember data as [2, 4, 4, 4, 5, 5, 7, 9]
28
+ show "mean: " + mean(data)
29
+ show "median: " + median(data)
30
+ show "variance: " + round(variance(data) * 100) / 100
31
+ show "deviation: " + round(deviation(data) * 100) / 100
@@ -1,3 +1,3 @@
1
- // PlainScript 1.0.361: module entry point.
1
+ // PlainScript 1.0.363: module entry point.
2
2
  import { circleArea } from "./math.pln"
3
3
  show circleArea(2)
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: named imports.
1
+ // PlainScript 1.0.363: named imports.
2
2
 
3
3
  import { circleArea } from "./math.pln"
4
4
  show circleArea(2)
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: an imported module.
1
+ // PlainScript 1.0.363: an imported module.
2
2
 
3
3
  remember PI as 3.14159
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: MongoDB.
1
+ // PlainScript 1.0.363: MongoDB.
2
2
  //
3
3
  // The `mongo` statement binds a connection to a MongoDB instance using the
4
4
  // official `mongodb` driver. Give it a connection string and an optional
@@ -0,0 +1,22 @@
1
+ // PlainScript 1.0.363 — the three declaration forms are one grammar.
2
+ // `let x is ...`, `let x be ...`, and `remember x as ...` compile to the
3
+ // same JavaScript; mix them freely and const/generalize them.
4
+ // A `make function` body that uses `yield` compiles to a generator function.
5
+
6
+ let a is 5
7
+ let b be 6
8
+ remember c as 7
9
+ show a + b + c
10
+
11
+ let celsius be 21
12
+ remember fahrenheit as celsius * 9 / 5 + 32
13
+ show "69.8 degrees computed: " + fahrenheit
14
+
15
+ let tick be 1
16
+ tick is now 2
17
+ show tick
18
+
19
+ let name be "ada"
20
+ name becomes "ada lovelace"
21
+ name change to "Ada Lovelace"
22
+ show name
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: object literals and member access.
1
+ // PlainScript 1.0.363: object literals and member access.
2
2
  remember user as {name: "Ada", active: true}
3
3
  show user.name
4
4
  user.active becomes false
package/examples/ocr.pln CHANGED
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: upload handling and OCR.
1
+ // PlainScript 1.0.363: upload handling and OCR.
2
2
 
3
3
  web app
4
4
  accept uploads limit "5 MB" allow list with "image/png", "image/jpeg" folder "uploads"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: importing npm packages.
1
+ // PlainScript 1.0.363: importing npm packages.
2
2
 
3
3
  use express
4
4
 
@@ -0,0 +1,32 @@
1
+ // PlainScript 1.0.363 — randomness without repeats and weighted picks.
2
+ // Usage:
3
+ // plainscript run examples/random-cli.pln
4
+ // plainscript run examples/random-cli.pln 20
5
+
6
+ make rollDice(sides)
7
+ give randomInteger(1, sides)
8
+ done
9
+
10
+ make main()
11
+ remember argv as args()
12
+ remember rolls as 6
13
+ if count of argv is at least 1
14
+ rolls becomes parseInt(argv at position 0, 10)
15
+ done
16
+ show "rolling a d6 " + rolls + " times:"
17
+ remember i as 0
18
+ remember sum as 0
19
+ while i is less than rolls
20
+ sum += rollDice(6)
21
+ i += 1
22
+ done
23
+ show "sum of rolls: " + sum
24
+ show "one die: " + rollDice(6)
25
+ show "coin: " + randomChoice(["heads", "tails"])
26
+ show "lucky card: " + randomChoice(["Ace", "King", "Queen", "Jack"])
27
+ show "weighted loot: " + weightedChoice(["common", "rare", "legendary"], [0.7, 0.25, 0.05])
28
+ show "shuffled deck: " + join(shuffle(["A", "2", "3", "4", "5"]), " ")
29
+ show "three of ten: " + join(sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3), " ")
30
+ done
31
+
32
+ main()
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: record kind construction.
1
+ // PlainScript 1.0.363: record kind construction.
2
2
  define a kind called "Player" with
3
3
  name is ""
4
4
  goals is 0
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: record kinds and record values.
1
+ // PlainScript 1.0.363: record kinds and record values.
2
2
 
3
3
  define a kind called "Player" with
4
4
  name is ""
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: fetch an upstream API from a route.
1
+ // PlainScript 1.0.363: fetch an upstream API from a route.
2
2
  web app
3
3
  route get "/proxy"
4
4
  remember upstream as get "https://example.com/data" timeout 5000
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: JSON REST route.
1
+ // PlainScript 1.0.363: JSON REST route.
2
2
  web app
3
3
  route get "/api/status"
4
4
  reply json
@@ -0,0 +1,25 @@
1
+ // PlainScript 1.0.363 — Promise.all-style concurrency with a named result.
2
+ // `run in parallel ... done as <name>` starts every call at once and collects
3
+ // the value of each statement into the named list, preserving order.
4
+
5
+ make square(n)
6
+ give n * n
7
+ done
8
+
9
+ make cube(n)
10
+ give n * n * n
11
+ done
12
+
13
+ run in parallel
14
+ square(3)
15
+ cube(3)
16
+ square(4)
17
+ done as results
18
+
19
+ show "results: " + join(results, ", ")
20
+
21
+ remember acc as 0
22
+ for each value in results
23
+ acc += value
24
+ done
25
+ show "sum: " + acc
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: recurring task.
1
+ // PlainScript 1.0.363: recurring task.
2
2
  schedule "0 * * * *"
3
3
  show "hourly task"
4
4
  done
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: collection filtering.
1
+ // PlainScript 1.0.363: collection filtering.
2
2
  remember values as list with 1, 2, 3
3
3
  remember found as first item from values
4
4
  show found
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: minimal server.
1
+ // PlainScript 1.0.363: minimal server.
2
2
  web app
3
3
  route get "/"
4
4
  reply "Hello from PlainScript"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: sessions and cookies.
1
+ // PlainScript 1.0.363: sessions and cookies.
2
2
  web app
3
3
  enable sessions "session-secret"
4
4
  route get "/"
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: SQLite, SQL blocks, parameters, and transactions.
1
+ // PlainScript 1.0.363: SQLite, SQL blocks, parameters, and transactions.
2
2
 
3
3
  database "plain-script-demo.db" using "wasm"
4
4
  remember personName as "Ada"
@@ -1,2 +1,2 @@
1
- // PlainScript 1.0.361: start command entry point.
1
+ // PlainScript 1.0.363: start command entry point.
2
2
  show "PlainScript started"
@@ -0,0 +1,29 @@
1
+ // PlainScript 1.0.363 — statistics over an arbitrary sample.
2
+ // Usage:
3
+ // plainscript run examples/stats-cli.pln 2 4 4 4 5 5 7 9
4
+ // New primitives: mean, median, variance, deviation, plus sort/first/last.
5
+
6
+ make toNumbers(raw)
7
+ remember numbers as []
8
+ for each item in raw
9
+ push(numbers, parseFloat(item))
10
+ done
11
+ give numbers
12
+ done
13
+
14
+ make report(numbers)
15
+ if count of numbers is 0
16
+ show "no numbers given; using the default sample"
17
+ numbers becomes [2, 4, 4, 4, 5, 5, 7, 9]
18
+ done
19
+ remember ordered as sort(numbers)
20
+ show "count: " + count of numbers
21
+ show "mean: " + round(mean(numbers) * 100) / 100
22
+ show "median: " + median(numbers)
23
+ show "variance: " + round(variance(numbers) * 100) / 100
24
+ show "deviation: " + round(deviation(numbers) * 100) / 100
25
+ show "lowest: " + first(ordered)
26
+ show "highest: " + last(ordered)
27
+ done
28
+
29
+ report(toNumbers(args()))
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: standard library helpers.
1
+ // PlainScript 1.0.363: standard library helpers.
2
2
  remember text as trim(" PlainScript ")
3
3
  remember digest as sha256(text)
4
4
  show digest
@@ -0,0 +1,23 @@
1
+ // PlainScript 1.0.363 — string helpers including the new parsing verbs.
2
+ // parseBoolean / characters / toUpperCase / toLowerCase / split / join.
3
+
4
+ remember raw as "true"
5
+ show parseBoolean(raw)
6
+
7
+ remember messy as " PlainScript "
8
+ show "[" + trim(messy) + "]"
9
+ show toUpperCase("whisper")
10
+ show toLowerCase("LOUD")
11
+
12
+ remember sentence as "the quick brown fox"
13
+ remember chars as characters("abc")
14
+ show "first char: " + chars at position 0
15
+ show "words: " + count of split(sentence, " ")
16
+
17
+ remember yesCount as 0
18
+ for each token in split("yes,no,1,off,true", ",")
19
+ if parseBoolean(token) is true
20
+ yesCount += 1
21
+ done
22
+ done
23
+ show "truthy tokens: " + yesCount
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: natural string verbs - transform a variable in place.
1
+ // PlainScript 1.0.363: natural string verbs - transform a variable in place.
2
2
 
3
3
  make capitalize(title)
4
4
  lowercase title
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: fixed and provider-backed Telegram replies.
1
+ // PlainScript 1.0.363: fixed and provider-backed Telegram replies.
2
2
 
3
3
  bot env("TELEGRAM_BOT_TOKEN")
4
4
 
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: Telegram bot.
1
+ // PlainScript 1.0.363: Telegram bot.
2
2
  bot env("TELEGRAM_BOT_TOKEN")
3
3
  when someone sends "/start"
4
4
  reply "Welcome"
@@ -0,0 +1,11 @@
1
+ // PlainScript 1.0.363 — terminal and process primitives.
2
+ // `terminalWidth()`, `terminalHeight()`, `clearTerminal()` and `stderr(...)`
3
+ // are CLI helpers. Error text goes to stderr so stdout stays clean.
4
+
5
+ stderr("starting terminal census")
6
+ show "width: " + terminalWidth()
7
+ show "height: " + terminalHeight()
8
+ stderr("clearing screen")
9
+ clearTerminal()
10
+ show "screen cleared"
11
+ stderr("done")
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: the native test DSL.
1
+ // PlainScript 1.0.363: the native test DSL.
2
2
 
3
3
  make add(a, b)
4
4
  give a + b
@@ -11,7 +11,7 @@ What the script exercises:
11
11
  - `remember scene as new THREE.Scene()`, `new THREE.PerspectiveCamera(...)`,
12
12
  `new THREE.WebGLRenderer()` and `renderer.setSize(...)`.
13
13
  - `new THREE.BoxGeometry(...)`, `new THREE.MeshStandardMaterial({ color: 0x40c463 })`
14
- and `new THREE.Mesh(geo, mat)` - v1.0.361 hex literals (`0xRRGGBB`) keep the
14
+ and `new THREE.Mesh(geo, mat)` - v1.0.363 hex literals (`0xRRGGBB`) keep the
15
15
  palette legible; the lights use `0xffffff`.
16
16
  - A light rig with `new THREE.AmbientLight(...)` + `new THREE.DirectionalLight(...)`.
17
17
  - `document.body.append(renderer.domElement)` mounts the WebGL canvas.
@@ -1,4 +1,4 @@
1
- // PlainScript 1.0.361: a WebGL 3D scene using the global THREE object.
1
+ // PlainScript 1.0.363: a WebGL 3D scene using the global THREE object.
2
2
 
3
3
  remember scene as new THREE.Scene()
4
4
  remember camera as new THREE.PerspectiveCamera(75, 640 / 480, 0.1, 1000)