diff options
| author | Andrey Listopadov <andreyorst@gmail.com> | 2022-10-31 18:17:11 +0300 |
|---|---|---|
| committer | Andrey Listopadov <andreyorst@gmail.com> | 2022-10-31 18:17:11 +0300 |
| commit | e7951b59b9168fc57d83b6a0aaaf1c31d56cfa7f (patch) | |
| tree | 84402b342a82925b1b68ade31a6eadf73378bf50 /doc/core.md | |
| parent | b8b60392a0dc450b85e8713323c8986bb350f7fe (diff) | |
update documentation for reduce and into
Diffstat (limited to 'doc/core.md')
| -rw-r--r-- | doc/core.md | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/doc/core.md b/doc/core.md index 014be20..578efef 100644 --- a/doc/core.md +++ b/doc/core.md @@ -1467,18 +1467,25 @@ Function signature: (into ([]) ([to]) ([to from]) ([to xform from])) ``` -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} @@ -1808,9 +1815,7 @@ Takes a value `x` and returns an infinite lazy sequence of this value. ### 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)))) ``` ## `repeatedly` |