add pow, work on sets

This commit is contained in:
Scott Richmond 2025-07-05 23:56:10 -04:00
parent 4f9ebdaeb1
commit e3683f82b5
6 changed files with 20 additions and 11 deletions

View File

@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
chumsky = "0.10.1"
imbl = "3.0.0"
imbl = "5.0.0"
num-derive = "0.4.2"
num-traits = "0.2.19"
regex = "1.11.1"
@ -19,3 +19,4 @@ serde_json = "1.0"
console_error_panic_hook = "0.1.7"
struct_scalpel = "0.1.1"
serde-wasm-bindgen = "0.6.5"
ordered-float = "5.0.0"

4
pkg/rudus.d.ts vendored
View File

@ -14,8 +14,8 @@ export interface InitOutput {
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_6: WebAssembly.Table;
readonly closure353_externref_shim: (a: number, b: number, c: any) => void;
readonly closure376_externref_shim: (a: number, b: number, c: any, d: any) => void;
readonly closure354_externref_shim: (a: number, b: number, c: any) => void;
readonly closure377_externref_shim: (a: number, b: number, c: any, d: any) => void;
readonly __wbindgen_start: () => void;
}

View File

@ -240,13 +240,13 @@ function _assertNum(n) {
function __wbg_adapter_20(arg0, arg1, arg2) {
_assertNum(arg0);
_assertNum(arg1);
wasm.closure353_externref_shim(arg0, arg1, arg2);
wasm.closure354_externref_shim(arg0, arg1, arg2);
}
function __wbg_adapter_46(arg0, arg1, arg2, arg3) {
_assertNum(arg0);
_assertNum(arg1);
wasm.closure376_externref_shim(arg0, arg1, arg2, arg3);
wasm.closure377_externref_shim(arg0, arg1, arg2, arg3);
}
async function __wbg_load(module, imports) {
@ -403,8 +403,8 @@ function __wbg_get_imports() {
_assertBoolean(ret);
return ret;
};
imports.wbg.__wbindgen_closure_wrapper8075 = function() { return logError(function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 354, __wbg_adapter_20);
imports.wbg.__wbindgen_closure_wrapper8124 = function() { return logError(function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 355, __wbg_adapter_20);
return ret;
}, arguments) };
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {

BIN
pkg/rudus_bg.wasm (Stored with Git LFS)

Binary file not shown.

View File

@ -9,6 +9,6 @@ export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_export_6: WebAssembly.Table;
export const closure353_externref_shim: (a: number, b: number, c: any) => void;
export const closure376_externref_shim: (a: number, b: number, c: any, d: any) => void;
export const closure354_externref_shim: (a: number, b: number, c: any) => void;
export const closure377_externref_shim: (a: number, b: number, c: any, d: any) => void;
export const __wbindgen_start: () => void;

View File

@ -179,6 +179,13 @@ pub fn mult(x: &Value, y: &Value) -> Value {
}
}
pub fn pow(x: &Value, y: &Value) -> Value {
match (x, y) {
(Value::Number(x), Value::Number(y)) => Value::Number(x.powf(*y)),
_ => unreachable!("internal ludus error: pow expects numbers"),
}
}
pub fn dissoc(dict: &Value, key: &Value) -> Value {
match (dict, key) {
(Value::Dict(dict), Value::Keyword(key)) => {
@ -669,6 +676,7 @@ pub fn make_base() -> Value {
Value::BaseFn(Box::new(BaseFn::Unary("number", number))),
),
("pi", Value::Number(std::f64::consts::PI)),
("pow", Value::BaseFn(Box::new(BaseFn::Binary("pow", pow)))),
(
"print!",
Value::BaseFn(Box::new(BaseFn::Unary("print!", print))),