Skip to content

Commit

Permalink
implement chain
Browse files Browse the repository at this point in the history
  • Loading branch information
verberktstan authored Dec 1, 2024
1 parent 97e4e36 commit 1092490
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/swark/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@
result {:result result :retries-left retries-left :n n}
:else (recur (dec retries-left))))))

(letfn [(chain-effect [f effect]
(comp f #(doto % effect)))]
(defn chain [f & effects]
(-> f ifn? assert)
(or
(some->> effects
(filter fn?)
seq
(reduce chain-effect f))
f)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Regarding strings

Expand Down

0 comments on commit 1092490

Please sign in to comment.