practicalli / practicalli/clojure

eduction

Open
#236 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clojure-core
Dominant language
Makefile
Stars
117
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Does anyone actually use eduction? It sounds great in theory but when I benchmark it once in a while, it does not seem to provide much, even with reduce

I see eduction as a way of attaching some transducer to a collection, while not doing anything yet. You can compose this many times, until you actually want to transduce the thing.

 user=> (def xform1 (map inc))
 #'user/xform1
 user=> (def e (eduction xform1 [1 2 3]))
 #'user/e
 user=> (into [] (map inc) e)
 [3 4 5]

range returns something that's a sequence, but also implements IReduce. Similarly, eduction returns something seqable and reducible. Useful in situations where you have a multi-stage pipeline, and each stage can return an eduction, and the rest can treat the previous stuff as sequences (which is especially useful for REPL-interaction).
This has the advantage of not having to write everything in transducers, while still getting the benefit when you do.

TIL that when you print an eduction, it actually realizes the thing?
$ clj -e '(prn (eduction (map inc) [1 2 3]))'
(2 3 4)

https://clojurians.slack.com/archives/C03S1KBA2/p1597007802144300?thread_ts=1597007802.144300&cid=C03S1KBA2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files or tests. Start by reproducing the shown clj command and reviewing the discussion about eduction, transducers, and printing behavior. A useful outcome would first define the documentation change or question to resolve, since the current issue does not specify one.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.