File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 11^{:kindly/hide-code true
22 :clay {:title " What if... we were taught transducers first?"
3+ :exception-continue true
34 :quarto {:author :seancorfield
45 :type :post
56 :date " 2025-05-31"
5758; ; We might be tempted to use `cons` here, but its argument order is different
5859; ; from `conj` so this will fail:
5960
60- (try (transduce (map inc) cons () (range 5 ))
61- (catch Exception e (ex-message e)))
61+ (transduce (map inc) cons () (range 5 ))
6262
6363; ; Okay, well, let's use an anonymous function to reverse the order of the
6464; ; arguments:
6565
66- (try (transduce (map inc) #(cons %2 %1 ) () (range 5 ))
67- (catch Exception e (ex-message e)))
66+ (transduce (map inc) #(cons %2 %1 ) () (range 5 ))
6867
69- ; ; Why is it trying to call `cons` with a single argument? In addition to
68+ ; ; Why is it trying to call our `cons` wrapper with a single argument? In addition to
7069; ; separating the transformation from the output, `transduce` also has a
7170; ; "completion" step, which is performed on the final result. A convenience
7271; ; function called `completing` can be used to wrap the function here to
You can’t perform that action at this time.
0 commit comments