Skip to content

Instantly share code, notes, and snippets.

@marcandrefontaine
marcandrefontaine / core.clj
Created April 20, 2019 16:17
Exit JavaFx for aot compilation
(when *compile-files*
(future (println "Process" (-> (java.lang.management.ManagementFactory/getRuntimeMXBean) .getName))
(println "Waiting 2 secs before exiting JavaFX platform")
(Thread/sleep 2000)
(println "Exiting JavaFX platform")
(Platform/setImplicitExit true)
(Platform/exit))
)
(defn -and
"(-and fn1 & more) given a set of functions returns ((-and fn1 fn2)x)=>(and (fn1 x) (fn2 x))"
([fn1] fn1)
([fn1 & more]
(fn [x]
(nil? (some false? ((apply juxt (vec (conj more fn1))) x))))
)
)
@marcandrefontaine
marcandrefontaine / mysubs
Created December 31, 2015 00:42
clojure subs with negative indexes
(defn newindex [s start]
(if (< start 0) (max 0 (- (count s) (* -1 start))) start)
)
(defn mysubs
([s start]
(let [newstart (newindex s start)]
(clojure.core/subs s 0 newstart)
)
)