Skip to content
Snippets Groups Projects
Commit 6f37628b authored by Cam Saül's avatar Cam Saül
Browse files

Merge pull request #215 from metabase/rpartial

rpartial util fn
parents 109709c3 afea6dcb
No related merge requests found
......@@ -149,3 +149,13 @@
false
(boolean (re-matches #"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
(clojure.string/lower-case v)))))
(defn rpartial
"Like `partial`, but applies additional args *before* BOUND-ARGS.
Inspired by [`-rpartial` from dash.el](https://github.com/magnars/dash.el#-rpartial-fn-rest-args)
((partial - 5) 8) -> (- 5 8) -> -3
((rpartial - 5) 8) -> (- 8 5) -> 3"
[f & bound-args]
(fn [& args]
(apply f (concat args bound-args))))
......@@ -28,3 +28,12 @@
:a 100
:b (+ 100 (:a <>))
:c (+ 100 (:b <>))))
;;; tests for RPARTIAL
(expect 3
((rpartial - 5) 8))
(expect -7
((rpartial - 5 10) 8))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment