Skip to content

Commit

Permalink
change return of destruct-map ; tag 0.7.11
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Aug 2, 2023
1 parent d212688 commit 8982480
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit"
version = "0.7.10"
version = "0.7.11"
authors = ["jiyinyiyong <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
10 changes: 7 additions & 3 deletions calcit/test-map.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,13 @@

println $ .destruct $ &{} :a 1 :b 2 :c 3
assert= true
list? $ nth (.destruct $ &{} :a 1 :b 2 :c 3) 0
assert= 2
count $ nth (.destruct $ &{} :a 1 :b 2 :c 3) 0
tag? $ nth (.destruct $ &{} :a 1 :b 2 :c 3) 0
assert= true
number? $ nth (.destruct $ &{} :a 1 :b 2 :c 3) 1
assert= true
map? $ nth (.destruct $ &{} :a 1 :b 2 :c 3) 2
assert= 3
count (.destruct $ &{} :a 1 :b 2 :c 3)

assert= 2
.count $ last $ .destruct $ &{} :a 1 :b 2 :c 3
Expand Down
6 changes: 3 additions & 3 deletions calcit/test-tuple.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
(:some l0 ls) (:: :parts (number? l0) (count ls))

assert=
:: :parts 2 1
:: :parts true true 1
tag-match (destruct-map $ &{} :a 1 :b 2)
(:none) (:: :empty)
(:some m0 ms) (:: :parts (count m0) (count ms))
(:some k0 v0 ms) (:: :parts (tag? k0) (number? v0) (count ms))

assert=
:: :empty
tag-match (destruct-map $ &{})
(:none) (:: :empty)
(:some m0 ms) (:: :parts (count m0) (count ms))
(:some k0 v0 ms) (:: :parts (count ms))

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcit/procs",
"version": "0.7.10",
"version": "0.7.11",
"main": "./lib/calcit.procs.mjs",
"devDependencies": {
"@types/node": "^20.4.4",
Expand Down
4 changes: 1 addition & 3 deletions src/builtins/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ pub fn destruct(xs: &CalcitItems) -> Result<Calcit, CalcitErr> {
Some(k0) => {
let mut zs = ys.to_owned();
zs.remove_mut(k0);
Ok(Calcit::List(
vec![Calcit::List(vec![k0.to_owned(), ys[k0].to_owned()].into()), Calcit::Map(zs)].into(),
))
Ok(Calcit::List(vec![k0.to_owned(), ys[k0].to_owned(), Calcit::Map(zs)].into()))
}
None => Ok(Calcit::Nil),
},
Expand Down
2 changes: 1 addition & 1 deletion src/cirru/calcit-core.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,7 @@
pair $ &map:destruct xs
if (nil? pair)
:: :none
:: :some (nth pair 0) (nth pair 1)
:: :some & pair

|optionally $ quote
defn optionally (s)
Expand Down
4 changes: 2 additions & 2 deletions ts-src/calcit.procs.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// CALCIT VERSION
export const calcit_version = "0.7.10";
export const calcit_version = "0.7.11";

import { parse, ICirruNode } from "@cirru/parser.ts";
import { writeCirruCode } from "@cirru/writer.ts";
Expand Down Expand Up @@ -504,7 +504,7 @@ export let _$n_map_$o_destruct = (xs: CalcitValue): CalcitValue => {
if (xs.len() > 0) {
let pair = xs.pairs()[0];
let k0 = pair[0];
return new CalcitSliceList([new CalcitSliceList(pair), xs.dissoc(k0)]);
return new CalcitSliceList([pair[0], pair[1], xs.dissoc(k0)]);
} else {
return null;
}
Expand Down

0 comments on commit 8982480

Please sign in to comment.