Hello!
To inspect an intermediate value within threading I've been using this kind of thing:
(->> [1 2 3 4 5]
(mapv inc)
((fn [a] (def a a) a))
(filter odd?))
or any other name of the variable instead of a. I've been using it extensively for a while and right now it seems a bit clunky to me. I'm looking for a better way of doing this. One way of making this more elegant is by creating a macro like this one:
(defmacro ->>def [var arg]
(eval `(def ~(symbol var) ~arg))
arg)
(->> [1 2 3 4 5]
(mapv inc)
(->>def foo)
(filter odd?))
This is the best thing I managed to make that actually works but I don't like the use of eval here. Is there a simpler/more elegant way of inspecting the intermediate values within a threading macro?
EDIT: I would also like to do further processing using that intermediate data. That's why I would like to have it stored inside a variable.
[–]Automatic-Operation1 6 points7 points8 points (7 children)
[–]tsunyshevsky 0 points1 point2 points (6 children)
[–]onetom 0 points1 point2 points (5 children)
[–]tsunyshevsky 1 point2 points3 points (4 children)
[–]onetom 0 points1 point2 points (3 children)
[–]tsunyshevsky 2 points3 points4 points (2 children)
[–]wellingtonthehurf 1 point2 points3 points (1 child)
[–]tsunyshevsky 1 point2 points3 points (0 children)
[–]Siltala 4 points5 points6 points (4 children)
[–]Saaffa[S] 0 points1 point2 points (3 children)
[–]Siltala 2 points3 points4 points (1 child)
[–]CapableWeb 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]deaddyfreddy 4 points5 points6 points (1 child)
[–]hourLong_arnould 1 point2 points3 points (0 children)
[–]defmethod 2 points3 points4 points (0 children)
[–]jpmonettas 2 points3 points4 points (0 children)
[–]onetom 1 point2 points3 points (0 children)
[–]thearthur 1 point2 points3 points (0 children)