diff options
| author | Andrey Listopadov <andreyorst@gmail.com> | 2021-02-19 20:19:37 +0300 |
|---|---|---|
| committer | Andrey Listopadov <andreyorst@gmail.com> | 2021-02-19 20:19:37 +0300 |
| commit | 60d99f85b6d4f0ec23ad21d3b1767084c5eb8b46 (patch) | |
| tree | b99703275e20b86146517cc132c988a30155dc74 /doc/cljlib.md | |
| parent | a0318645ec4ed7f4bfa6ab50d0a5ee7fc67b8006 (diff) | |
fix: release 0.5.1
- eq will no longer change metamethods of tables
- module info is hidden in metatable now
- memoize uses proper deep comparison
- tests no longer requires searching up in core namespace
- memoization test doesn't depend on CPU speed anymore
Diffstat (limited to 'doc/cljlib.md')
| -rw-r--r-- | doc/cljlib.md | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/doc/cljlib.md b/doc/cljlib.md index 4963bf0..61765d4 100644 --- a/doc/cljlib.md +++ b/doc/cljlib.md @@ -1,4 +1,4 @@ -# Cljlib (0.5.0) +# Cljlib (0.5.1) Fennel-cljlib - functions from Clojure's core.clj implemented on top of Fennel. @@ -186,7 +186,7 @@ Divide arbitrary amount of numbers. Function signature: ``` -(le ([x]) ([x y]) ([x y & more])) +(le ([a]) ([a b]) ([a b & [c d & more]])) ``` Returns true if nums are in monotonically non-decreasing order @@ -195,7 +195,7 @@ Returns true if nums are in monotonically non-decreasing order Function signature: ``` -(lt ([x]) ([x y]) ([x y & more])) +(lt ([a]) ([a b]) ([a b & [c d & more]])) ``` Returns true if nums are in monotonically decreasing order @@ -204,7 +204,7 @@ Returns true if nums are in monotonically decreasing order Function signature: ``` -(ge ([x]) ([x y]) ([x y & more])) +(ge ([a]) ([a b]) ([a b & [c d & more]])) ``` Returns true if nums are in monotonically non-increasing order @@ -213,7 +213,7 @@ Returns true if nums are in monotonically non-increasing order Function signature: ``` -(gt ([x]) ([x y]) ([x y & more])) +(gt ([a]) ([a b]) ([a b & [c d & more]])) ``` Returns true if nums are in monotonically increasing order @@ -245,6 +245,27 @@ Function signature: Deep compare values. +### Examples + +[`eq`](#eq) can compare both primitive types, tables, and user defined types +that have `__eq` metamethod. + +``` fennel +(assert-is (eq 42 42)) +(assert-is (eq [1 2 3] [1 2 3])) +(assert-is (eq (hash-set :a :b :c) (hash-set :a :b :c))) +(assert-is (eq (hash-set :a :b :c) (ordered-set :c :b :a))) +``` + +Deep comparison is used for tables which use tables as keys: + +``` fennel +(assert-is (eq {[1 2 3] {:a [1 2 3]} {:a 1} {:b 2}} + {{:a 1} {:b 2} [1 2 3] {:a [1 2 3]}})) +(assert-is (eq {{{:a 1} {:b 1}} {{:c 3} {:d 4}} [[1] [2 [3]]] {:a 2}} + {[[1] [2 [3]]] {:a 2} {{:a 1} {:b 1}} {{:c 3} {:d 4}}})) +``` + ## `map?` Function signature: |