Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Issue #7] got -?<> working

  • Loading branch information...
commit 8305875b2411ab563f5e3a7c3f5da7a1654ffe6a 1 parent 59042b7
@AlexBaranosky authored
View
3  project.clj
@@ -1,4 +1,5 @@
(defproject swiss-arrows "0.1.0"
:description "more arrow macros"
- :dependencies [[org.clojure/clojure "1.3.0"]]
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [org.clojure/core.incubator "0.1.0"]]
:dev-dependencies [[midje "1.3.0"]])
View
9 src/swiss_arrows/core.clj
@@ -1,4 +1,5 @@
-(ns swiss-arrows.core)
+(ns swiss-arrows.core
+ (:require [clojure.core.incubator :as incubator]))
(defmacro -<>
"the 'diamond wand': pass a needle through variably positioned holes
@@ -69,3 +70,9 @@
"parallel diamond fishing rod"
[form & branches]
`(furcula* -<> :parallel ~form ~branches))
+
+(defmacro nilsafe-arrow [docstring non-nilsafe nilsafe]
+ (#'incubator/defnilsafe &form &env docstring non-nilsafe nilsafe))
+
+(nilsafe-arrow "the nullsafe version of -<>"
+ -<> -?<>)
View
10 test/swiss_arrows/test/core.clj
@@ -175,4 +175,12 @@
(do (Thread/sleep 1000))
(do (Thread/sleep 1000))))))
#"[^\d\.]" ""))
- => (roughly 3000 3005))
+ => (roughly 3000 3005))
+
+(facts "about null-safe swiss arrows"
+
+ (-?<> "abc"
+ (if (string? "adf") nil <>)
+ (str <> " + more"))
+ => nil
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.