-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added reducer and transducer as alternatives to
Stream
and Filter
.
- Loading branch information
1 parent
06c182d
commit 22efb27
Showing
42 changed files
with
517 additions
and
40 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
documentation/bookmark/api__application_programming_interface.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
documentation/bookmark/design/ui__user_interface/cli__command_line_interface.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.using | ||
[library | ||
[lux (.except)]]) | ||
|
||
... https://clojure.org/reference/reducers | ||
... https://clojure.org/news/2012/05/08/reducers | ||
... https://clojure.org/news/2012/05/15/anatomy-of-reducer | ||
(every .public (Reduction piece whole) | ||
(-> piece whole | ||
whole)) | ||
|
||
... https://clojure.org/reference/transducers | ||
... https://en.wikipedia.org/wiki/Transduction | ||
(every .public (Transduction to_consume to_produce | ||
outer_whole inner_whole) | ||
(-> (Reduction to_produce inner_whole) | ||
(Reduction to_consume outer_whole))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.using | ||
[library | ||
[lux (.except only and) | ||
["[0]" function (.only) | ||
[predicate (.only Predicate)] | ||
[polytypism | ||
[mix (.only Mix)]]] | ||
[error | ||
["[0]" try]] | ||
[data | ||
[collection | ||
["[0]" dictionary (.only Dictionary)]]]]] | ||
["[0]" //]) | ||
|
||
(every .public (Transduction to_consume to_produce whole) | ||
(//.Transduction to_consume to_produce | ||
whole whole)) | ||
|
||
(the .public nothing | ||
(for_any (_ it) | ||
(Transduction it it)) | ||
function.identity) | ||
|
||
(the .public and | ||
(for_any (_ to_consume in_transit to_produce) | ||
(-> (Transduction to_consume in_transit) (Transduction in_transit to_produce) | ||
(Transduction to_consume to_produce))) | ||
function.composite) | ||
|
||
(the .public (each it) | ||
(for_any (_ to_consume to_produce) | ||
(-> (-> to_consume to_produce) | ||
(Transduction to_consume to_produce))) | ||
(function (_ mix part whole) | ||
(mix (it part) whole))) | ||
|
||
(the .public (only ?) | ||
(for_any (_ it) | ||
(-> (Predicate it) | ||
(Transduction it it))) | ||
(function (_ mix part whole) | ||
(if (? part) | ||
(mix part whole) | ||
whole))) | ||
|
||
(the .public (many collection::mix) | ||
(for_any (_ collection it) | ||
(-> (Mix collection) | ||
(Transduction (collection it) it))) | ||
(function (_ mix part whole) | ||
(collection::mix mix whole part))) | ||
|
||
(the .public maybe | ||
(for_any (_ it) | ||
(Transduction (Maybe it) it)) | ||
(function (_ mix part whole) | ||
(when part | ||
{.#Some part} | ||
(mix part whole) | ||
|
||
{.#None} | ||
whole))) | ||
|
||
(the .public (replaced replacements) | ||
(for_any (_ it) | ||
(-> (Dictionary it it) | ||
(Transduction it it))) | ||
(function (_ mix part whole) | ||
(mix (|> replacements | ||
(dictionary.value part) | ||
(try.else part)) | ||
whole))) | ||
|
||
(the .public (in_series mix initial | ||
transduction | ||
collection::mix collection) | ||
(for_any (_ collection to_consume to_mix whole) | ||
(-> (//.Reduction to_mix whole) whole | ||
(Transduction to_consume to_mix) | ||
(Mix collection) (collection to_consume) | ||
whole)) | ||
(collection::mix (transduction mix) initial collection)) |
Oops, something went wrong.