It's the first time I come up with a solution similar to yours :) I enjoy your videos a lot, always super insightful!
@MartinClausen Жыл бұрын
Isn't the order of args to comp the reversed. According to the doc string comp applies its arguments right to left. As an example: ((comp str +) 8 8 8) => "24". I don't understand how the tests would pass.
@fredoverflow Жыл бұрын
The rightmost TRANSDUCER runs first (only once total), but the leftmost REDUCING FUNCTION runs first (once per element). Copy/paste comment from my first Transducers video: Are you familiar with the Decorator Design Pattern? Consider new BufferedReader(new FileReader(file)) During construction, the FileReader CONSTRUCTOR runs first. But later during actual use, the BufferedReader OBJECT acts first and delegates to the FileReader OBJECT. Makes sense? Same with transducers. ((comp f g) x) indeed means (f (g x)), so during construction, the TRANSDUCER g runs first. But later during actual use, the REDUCING FUNCTION that f returned runs first (not f itself!) and delegates to the REDUCING FUNCTION that g returned (not g itself!)