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 1
1
^{:kindly/hide-code true
2
2
:clay {:title " What if... we were taught transducers first?"
3
+ :exception-continue true
3
4
:quarto {:author :seancorfield
4
5
:type :post
5
6
:date " 2025-05-31"
57
58
; ; We might be tempted to use `cons` here, but its argument order is different
58
59
; ; from `conj` so this will fail:
59
60
60
- (try (transduce (map inc) cons () (range 5 ))
61
- (catch Exception e (ex-message e)))
61
+ (transduce (map inc) cons () (range 5 ))
62
62
63
63
; ; Okay, well, let's use an anonymous function to reverse the order of the
64
64
; ; arguments:
65
65
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 ))
68
67
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
70
69
; ; separating the transformation from the output, `transduce` also has a
71
70
; ; "completion" step, which is performed on the final result. A convenience
72
71
; ; function called `completing` can be used to wrap the function here to
You can’t perform that action at this time.
0 commit comments