Skip to content

Commit 1256258

Browse files
authored
Merge pull request #28 from seancorfield/inline-exceptions
rely on exceptions being shown inline
2 parents 66ab938 + 9d7facc commit 1256258

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/clojure/transducers/what_if.clj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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"
@@ -57,16 +58,14 @@
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

0 commit comments

Comments
 (0)