Skip to content

Commit

Permalink
add contains-in? ; bump 0.4.31
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Sep 11, 2021
1 parent 23c5ffe commit c664790
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 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_runner"
version = "0.4.30"
version = "0.4.31"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
14 changes: 14 additions & 0 deletions calcit/snapshots/test-lens.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@
assoc-in nil ([] :a :b :c) 10
{} $ :a $ {} $ :b $ {} $ :c 10

assert= true
contains-in? (&{} :a ([] 1 2 3)) $ [] :a 1
assert= false
contains-in? (&{} :a ([] 1 2 3)) $ [] :a 3
assert= false
contains-in? (&{} :a ([] 1 2 3)) $ [] :b 1

assert= true
contains-in? ([] 1 2 $ [] 3 4) ([] 2 1)
assert= false
contains-in? ([] 1 2 $ [] 3 4) ([] 2 2)
assert= false
contains-in? ([] 1 2 $ [] 3 4) ([] 3 2)

|main! $ quote
defn main! ()

Expand Down
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.4.30",
"version": "0.4.31",
"main": "./lib/calcit.procs.js",
"devDependencies": {
"@types/node": "^16.7.10",
Expand Down
21 changes: 21 additions & 0 deletions src/cirru/calcit-core.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,27 @@
if (list? x) (&list:contains? x k)
.contains? x k

|contains-in? $ quote
defn contains-in? (xs path)
if (empty? path) true
&let
p0 $ first path
cond
(list? xs)
if
and (number? p0) (&list:contains? xs p0)
recur (nth xs p0) (rest path)
, false
(map? xs)
if (&map:contains? xs p0)
recur (&map:get xs p0) (rest path)
, false
(record? xs)
if (&record:contains? xs p0)
recur (&record:get xs p0) (rest path)
, false
true false

|includes? $ quote
defn includes? (x k)
if (nil? x) false
Expand Down
2 changes: 1 addition & 1 deletion ts-src/calcit.procs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// CALCIT VERSION
export const calcit_version = "0.4.30";
export const calcit_version = "0.4.31";

import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree";
import { parse } from "@cirru/parser.ts";
Expand Down

0 comments on commit c664790

Please sign in to comment.