Compare commits

..

No commits in common. "3d0b58e6ed2889bcd64bce1d4056e4544a4ae3e3" and "bed1f7933e71a2346ebf8481566db4699d4fb296" have entirely different histories.

8 changed files with 23 additions and 22 deletions

View File

@ -2,7 +2,8 @@
## Ludus: A friendly, dynamic, functional language ## Ludus: A friendly, dynamic, functional language
Ludus is a scripting programming language that is designed to be friendly, dynamic, and functional. Ludus is a scripting programming language that is designed to be friendly, dynamic, and functional.
This repo currently contains a work-in-progress implementation of an interpreter for the Ludus programming language, using [Janet](https://janet-lang.org) as a host language. This repo currently contains an in-progress reference implementation of an interpreter for the Ludus programming language, using Clojure as a host language.
Ludus is part of the [_Thinking with Computers_ project](https://alea.ludus.dev/twc/), run by Scott Richmond at the University of Toronto, with collaborator Matt Nish-Lapidus; Bree Lohman and Mynt Marsellus are the RAs for the project. Ludus is our research language, which aspires to be a free translation of Logo for the 2020s. Ludus is part of the [_Thinking with Computers_ project](https://alea.ludus.dev/twc/), run by Scott Richmond at the University of Toronto, with collaborator Matt Nish-Lapidus; Bree Lohman and Mynt Marsellus are the RAs for the project. Ludus is our research language, which aspires to be a free translation of Logo for the 2020s.
Here are our design goals: Here are our design goals:

Binary file not shown.

View File

@ -6489,7 +6489,7 @@ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])(); var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1); var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5); var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1825664; var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1803884;
function invoke_i(index) { function invoke_i(index) {
var sp = stackSave(); var sp = stackSave();
try { try {

Binary file not shown.

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@ludus/ludus-js-pure", "name": "@ludus/ludus-js-pure",
"version": "0.1.17", "version": "0.1.16",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@ludus/ludus-js-pure", "name": "@ludus/ludus-js-pure",
"version": "0.1.17", "version": "0.1.16",
"license": "GPL-3.0", "license": "GPL-3.0",
"devDependencies": { "devDependencies": {
"shadow-cljs": "^2.26.0", "shadow-cljs": "^2.26.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@ludus/ludus-js-pure", "name": "@ludus/ludus-js-pure",
"version": "0.1.17", "version": "0.1.16",
"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",

View File

@ -5,7 +5,7 @@
fn and fn and
fn append fn append
fn apply_command fn apply_command
fn assoc fn assoc & ?
fn atan/2 fn atan/2
fn deg/rad fn deg/rad
fn dict fn dict
@ -15,7 +15,6 @@ fn get
fn join fn join
fn mod fn mod
fn neg? fn neg?
fn print!
fn some? fn some?
fn state/call fn state/call
fn store! fn store!
@ -191,13 +190,15 @@ fn list {
fn fold { fn fold {
"Folds a list." "Folds a list."
(f as :fn, xs as :list) -> fold (f, xs, f ()) (f as :fn, xs as :list) -> fold (f, xs, f ())
(f as :fn, xs as :list, root) -> loop (root, first (xs), rest (xs)) with { (f as :fn, xs as :list, root) -> {
(prev, curr, []) -> f (prev, curr) loop (root, first (xs), rest (xs)) with {
(prev, curr, remaining) -> recur ( (prev, curr, []) -> f (prev, curr)
f (prev, curr) (prev, curr, remaining) -> recur (
first (remaining) f (prev, curr)
rest (remaining) first (remaining)
) rest (remaining)
)
}
} }
} }
@ -374,15 +375,12 @@ fn strip {
fn words { fn words {
"Takes a string and returns a list of the words in the string. Strips all whitespace." "Takes a string and returns a list of the words in the string. Strips all whitespace."
(str as :string) -> { (str as :string) -> {
print! (str)
let no_punct = strip (str) let no_punct = strip (str)
print! (no_punct)
let strs = split (no_punct, " ") let strs = split (no_punct, " ")
print! (strs)
fn worder (list, str) -> if empty? (str) fn worder (list, str) -> if empty? (str)
then do list > report! then list
else do append (list, str) > report! else append (list, str)
do fold (worder, strs, []) > report! fold (worder, strs, [])
} }
} }
@ -625,7 +623,7 @@ fn max {
& additional list operations now that we have comparitors & additional list operations now that we have comparitors
fn at { fn at {
"Returns the element at index n of a list or tuple, or the byte at index n of a string. Zero-indexed: the first element is at index 0. Returns nil if nothing is found in a list or tuple; returns an empty string if nothing is found in a string." "Returns the element at index n of a list or tuple, or the byte at index n of a string. Zero-indexed: the first element is at index 0. Returns nil if nothing is found in a list or tuple; returns an empty string if nothing is found in a string."
(xs as :list, n as :number) -> base :nth (n, xs) (xs as :list, n as :number) -> base :nth (xs, n)
(xs as :tuple, n as :number) -> base :nth (n, xs) (xs as :tuple, n as :number) -> base :nth (n, xs)
(str as :string, n as :number) -> when { (str as :string, n as :number) -> when {
neg? (n) -> "" neg? (n) -> ""

View File

@ -52,7 +52,9 @@
(comment (comment
# (do # (do
(def source ` (def source `
fold (add, [1, 2, 3]) let myset = ${1, 2, 3, 3, 2}
omit (2, myset)
myset
`) `)
(def out (-> source (def out (-> source
ludus ludus