Skip to content

Commit

Permalink
add get helpers for min/max keys; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Aug 3, 2020
1 parent 2f96923 commit b80c5c5
Show file tree
Hide file tree
Showing 9 changed files with 505 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- master

jobs:
upload-assets:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bisection-key
### Usage

```edn
[cirru/bisection-key "0.1.5"]
[cirru/bisection-key "0.1.6-a1"]
```

[![Clojars Project](https://img.shields.io/clojars/v/cirru/bisection-key.svg)](https://clojars.org/cirru/bisection-key)
Expand All @@ -32,6 +32,9 @@ bisection-key.core/max-id ; "z"
(bisection-key.util/assoc-before v "b" 2) ; (assoc v "aT" 2)
(bisection-key.util/assoc-prepend v 2) ; (assoc v "G" 2)
(bisection-key.util/assoc-append v 2) ; (assoc v "n" 2)

(bisection-key.util/get-min-key v) ; "a"
(bisection-key.util/get-max-key v) ; "b"
```

Charset:
Expand Down
372 changes: 259 additions & 113 deletions calcit.cirru

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
:aliases {
:release {
:extra-deps {
appliedscience/deps-library {:mvn/version "0.3.4"}
applied-science/deps-library {:mvn/version "0.4.0"}
}
:main-opts ["-m" "deps-library.release"]
:main-opts ["-m" "applied-science.deps-library"]
}
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bisection-key",
"version": "0.1.5",
"version": "0.1.6-a1",
"description": "Bisection key library",
"main": "index.js",
"scripts": {
Expand All @@ -18,9 +18,9 @@
"author": "jiyinyiyong",
"license": "MIT",
"devDependencies": {
"shadow-cljs": "^2.8.94",
"source-map-loader": "^0.2.4",
"ws": "^7.2.3"
"shadow-cljs": "^2.10.19",
"source-map-loader": "^1.0.1",
"ws": "^7.3.1"
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion release.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:version "0.1.5"
{:version "0.1.6-a1"
:group-id "cirru"
:artifact-id "bisection-key"
:skip-tag true
Expand Down
10 changes: 9 additions & 1 deletion src/bisection_key/test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
key-prepend
key-append
assoc-prepend
assoc-append]]))
assoc-append
get-min-key
get-max-key]]))

(deftest
test-append
Expand Down Expand Up @@ -51,6 +53,12 @@
(let [new-id (bisect min-id x)] (if (<= i 40) (recur (inc i) new-id) x)))
"++++++/")))

(deftest
test-get-key
(testing "get min key" (is (= "a" (get-min-key {"a" 1, "b" 2}))))
(testing "get max key" (is (= "b" (get-max-key {"a" 1, "b" 2}))))
(testing "get nil" (is (= nil (get-min-key {}))) (is (= nil (get-max-key {})))))

(deftest
test-key-after
(is (= (key-after {"a" 1, "b" 1} "a") "aT"))
Expand Down
4 changes: 4 additions & 0 deletions src/bisection_key/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
(defn assoc-prepend [dict v]
(assert (map? dict) "dict should be a map")
(let [k (key-prepend dict)] (assoc dict k v)))

(defn get-max-key [x] (apply max (keys x)))

(defn get-min-key [x] (apply min (keys x)))
Loading

0 comments on commit b80c5c5

Please sign in to comment.