summaryrefslogtreecommitdiff
path: root/init.fnl
diff options
context:
space:
mode:
authorAndrey Listopadov <andreyorst@gmail.com>2022-10-31 18:17:11 +0300
committerAndrey Listopadov <andreyorst@gmail.com>2022-10-31 18:17:11 +0300
commite7951b59b9168fc57d83b6a0aaaf1c31d56cfa7f (patch)
tree84402b342a82925b1b68ade31a6eadf73378bf50 /init.fnl
parentb8b60392a0dc450b85e8713323c8986bb350f7fe (diff)
update documentation for reduce and into
Diffstat (limited to 'init.fnl')
-rw-r--r--init.fnl19
1 files changed, 12 insertions, 7 deletions
diff --git a/init.fnl b/init.fnl
index bf56859..6b33e17 100644
--- a/init.fnl
+++ b/init.fnl
@@ -1298,9 +1298,7 @@ collection is provided."
# Examples
``` fennel
-(assert-eq 10 (accumulate [res 0
- _ x (pairs (take 10 (repeat 1)))]
- (+ res x)))
+(assert-eq 20 (reduce add (take 10 (repeat 2))))
```"
[x]
(seq* (lazy.repeat x)))
@@ -2050,18 +2048,25 @@ raise an error."
;;; Into
(defn into
- "Returns a new coll consisting of `to` with all of the items of
- `from` conjoined. A transducer `xform` may be supplied.
+ "Returns a new coll consisting of `to` with all of the items of `from`
+conjoined. A transducer `xform` may be supplied.
# Examples
-Thransofmr a hash-map into a sequence of key-value pairs:
+Insert items of one collection into another collection:
+
+```fennel
+(assert-eq [1 2 3 :a :b :c] (into [1 2 3] \"abc\"))
+(assert-eq {:a 2 :b 3} (into {:a 1} {:a 2 :b 3}))
+```
+
+Transform a hash-map into a sequence of key-value pairs:
``` fennel
(assert-eq [[:a 1]] (into (vector) {:a 1}))
```
- Construct a hash-map from a sequence of key-value pairs:
+You can also construct a hash-map from a sequence of key-value pairs:
``` fennel
(assert-eq {:a 1 :b 2 :c 3}