From e7951b59b9168fc57d83b6a0aaaf1c31d56cfa7f Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Mon, 31 Oct 2022 18:17:11 +0300 Subject: update documentation for reduce and into --- doc/core.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'doc') 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` -- cgit v1.2.3