Вот подход, использующий exception монады в cats библиотеки:
(ns your-project.core
(:require [cats.monad.exception :as e]))
(let [numbers [3 3 0 3]
results (->> numbers
(map #(e/try-on (/ 3 %))) ; wrap division result in a try
(take-while e/success?) ; take values while successful
(mapv e/extract))] ; unwrap the values from the trys
results)
;; => [1 1]
И если вы хотите сохранить значения, которые приходят после исключения:
(let [numbers [3 3 0 3]
results (->> numbers
(map #(e/try-on (/ 3 %)))
(filter e/success?) ; filter all successful values
(mapv e/extract))]
results)
;; => [1 1 1]
Я бы заменил «Throwable» на «Exception» здесь. Обычно подавление Java ['Error'] (http://docs.oracle.com/javase/7/docs/api/java/lang/Error.html) не является хорошей идеей. – OlegTheCat
'ex' ->' _' ... – OlegTheCat