From 60d99f85b6d4f0ec23ad21d3b1767084c5eb8b46 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Fri, 19 Feb 2021 20:19:37 +0300 Subject: 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 --- doc/cljlib.md | 31 ++++++++++++++++++++++++++----- doc/macros.md | 2 +- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'doc') 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: diff --git a/doc/macros.md b/doc/macros.md index d657eb8..d834c0a 100644 --- a/doc/macros.md +++ b/doc/macros.md @@ -1,4 +1,4 @@ -# Macros.fnl (0.5.0) +# Macros.fnl (0.5.1) Macros for Cljlib that implement various facilities from Clojure. **Table of contents** -- cgit v1.2.3