#60
Sequence Reductions
 

Difficulty:Medium
Topics:seqs core-functions


Write a function which behaves like reduce, but returns each intermediate value of the reduction. Your function must accept either two or three arguments, and the return sequence must be lazy.
test not run
(= (take 5 (__ + (range))) [0 1 3 6 10])
test not run
(= (__ conj [1] [2 3 4]) [[1] [1 2] [1 2 3] [1 2 3 4]])
test not run
(= (last (__ * 2 [3 4 5])) (reduce * 2 [3 4 5]) 120)
Special Restrictions
  • reductions


  • Code which fills in the blank: