Closed oubiwann closed 9 years ago
Some additional "reading": the talk "Transducers" by Rich Hickey (https://www.youtube.com/watch?v=6mTbuzafcII)
I am going to be difficult here and say that I don't really like that style of doing things. I prefer to be very explicit in my data types. Explicit in algorithms and explicit in data types.
There is a more practical issue and that is doing it efficiently. Check out gb_trees:iterator/1, http://erlang.org/doc/man/gb_trees.html#iterator-1, which creates something like this which can be used with gb_trees:next/1 to step through the tree. With these you could do a lot of these functions but ti would be more efficient to implement them directly.
You could of course have a transducer module with a set of these functions into which you could plug you transducer functions, but I wouldn't replace the direct functions with them.
Robert
I agree that LFE wouldn't benefit as much from transducers as Clojure does, since in Clojure you can apply these to more than just data structures. What I like about them is that they allow you to essentially build a folding function by composing a few transducers, and that all of these are applied in a single pass through the data structure. So I think this approach can improve readability, while keeping the efficiency of a single-pass fold. It could be fun to try to implement a transducer module inside lutils and see where it takes us. Sorry for not replying sooner; I should have a bit more time on my hands next week :)
@osense After @rvirding's suggestion on the mail list, I've created two repos:
And will be copying all of the Clojure-inspired code out of here and into the second repo. This will keep things more focused. Should be a lot of fun :-) I'm looking forward to hacking on both of those ...
Additional Note: for the clj repo, I'll actually be copying the code from lutil, removing the unused files, and then pruning the git history. This will preserve all contributions/git history made to date.
Moved to: https://github.com/lfex/clj/issues/5
Need to spend some more time reading about them, but so far it seems that it could provide a nice means of using a single set of functions for
map
,foldl
,filter
,take
, etc., without having to write a different one for each type (lists, maps, dicts, tulpes, sets, etc.).We'll see.
Reading: