diff --git a/Cargo.lock b/Cargo.lock index f934683b..0e03084b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "calcit_runner" -version = "0.3.0-a7" +version = "0.3.0-a8" dependencies = [ "cirru_edn", "cirru_parser", diff --git a/Cargo.toml b/Cargo.toml index 5954101d..2908d1b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "calcit_runner" -version = "0.3.0-a7" +version = "0.3.0-a8" authors = ["jiyinyiyong "] edition = "2018" license = "MIT" diff --git a/package.json b/package.json index f223e225..d10a7740 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@calcit/procs", - "version": "0.3.0-a7", + "version": "0.3.0-a8", "main": "./lib/calcit.procs.js", "devDependencies": { "@types/node": "^14.14.41", diff --git a/src/builtins.rs b/src/builtins.rs index b1f707e9..1aaac9e0 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -47,6 +47,7 @@ pub fn is_proc_name(s: &str) -> bool { | "&<" | "&>" | "not" + | "identical?" // math | "&+" | "&-" @@ -166,6 +167,8 @@ pub fn handle_proc(name: &str, args: &CalcitItems) -> Result { "&<" => logics::binary_less(args), "&>" => logics::binary_greater(args), "not" => logics::not(args), + // in Rust, no real pointer `identical?`, fallback to value equal + "identical?" => logics::binary_equal(args), // math "&+" => math::binary_add(args), "&-" => math::binary_minus(args), diff --git a/src/builtins/sets.rs b/src/builtins/sets.rs index f838e389..8c44248e 100644 --- a/src/builtins/sets.rs +++ b/src/builtins/sets.rs @@ -33,7 +33,15 @@ pub fn call_exclude(xs: &CalcitItems) -> Result { } pub fn call_difference(xs: &CalcitItems) -> Result { match (xs.get(0), xs.get(1)) { - (Some(Calcit::Set(a)), Some(Calcit::Set(b))) => Ok(Calcit::Set(a.clone().difference(b.clone()))), + (Some(Calcit::Set(a)), Some(Calcit::Set(b))) => { + // im::HashSet::difference has different semantics + // https://docs.rs/im/12.2.0/im/struct.HashSet.html#method.difference + let mut ys = a.to_owned(); + for item in b { + ys.remove(item); + } + Ok(Calcit::Set(ys)) + } (Some(a), Some(b)) => Err(format!("&difference expected 2 sets: {} {}", a, b)), (a, b) => Err(format!("&difference expected 2 arguments: {:?} {:?}", a, b)), } diff --git a/src/primes.rs b/src/primes.rs index e8eb1d68..06dd7581 100644 --- a/src/primes.rs +++ b/src/primes.rs @@ -408,7 +408,7 @@ impl PartialEq for Calcit { pub const CORE_NS: &str = "calcit.core"; pub const GENERATED_NS: &str = "calcit.gen"; -pub const CALCI_VERSION: &str = "0.3.0-a7"; +pub const CALCI_VERSION: &str = "0.3.0-a8"; impl Calcit { pub fn turn_string(&self) -> String {