This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn compile-unrolled | |
[f inputs] | |
(let [clauses (mapcat #(list % (f %)) inputs)] | |
`(fn [x#] | |
(case x# | |
~@clauses | |
(~f x#))))) | |
(defn unrolled | |
"Return a function with precomputed lookup for the given input domain." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; MrMusAddict's original function | |
(def charge-max 100.0) | |
(def charge-min 0.0) | |
(def bright-max 0.9) | |
(def bright-min 0.0) | |
;;; float brightFinal = (brightMin-brightMax)*Math.Pow((chargeCurrent-chargeMax)/(chargeMax-chargeMin), 4)+brightMax; | |
(defn mr-mus-addict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; now with an escape hatch! | |
(deftest home-page-flow | |
(naturally | |
(navigate to "/") | |
(click link "Sign In") | |
(fill in "Username" with $username, "Password" $password) | |
(click button "Sign In") | |
(expect page to have content "Welcome, " $username))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSIndexPath *)nextIndexPath:(NSIndexPath *)i | |
{ | |
// apologies to any maintainer but this was some code golf going on in #iphonedev | |
id t=_tableView; | |
int s,r,n;s=i.section;r=(i.row+1)%[t numberOfRowsInSection:s];n=[t numberOfSections]; | |
if(!r)for(;s<n&&![t numberOfRowsInSection:s+++1];); | |
return s==n?nil:[NSIndexPath indexPathForRow:r inSection:s]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro let-futures | |
[bindings & body] | |
(let [binding-pairs (partition 2 bindings) | |
future-syms (set (map first binding-pairs)) | |
binding-vector (vec (mapcat (fn [[l r]] [l (list 'future r)]) binding-pairs)) | |
body-code (clojure.walk/walk | |
(fn derefify [x] | |
(if (future-syms x) | |
(list 'clojure.core/deref x) | |
(clojure.walk/walk derefify identity x))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thumbsDown=$(printf "\xF0\x9F\x91\x8E") | |
thumbsUp=$(printf "\xF0\x9F\x91\x8D") | |
function exitIcon() | |
{ | |
if [ $? -eq 0 ] | |
then | |
echo $thumbsUp | |
else | |
echo $thumbsDown | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns speedtest) | |
(defn with-args | |
"Count down from n, return 0" | |
[n] | |
(if (< 0 n) | |
(recur (dec n)) | |
0)) | |
(defn with-state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; (macroexpand-1 '(go (+ 1 1)) yields ... | |
(clojure.core/let | |
[c__2247__auto__ | |
(clojure.core.async/chan 1) | |
captured-bindings__2248__auto__ | |
(clojure.lang.Var/getThreadBindingFrame)] | |
(clojure.core.async.impl.dispatch/run | |
(clojure.core/fn | |
[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn run-game! | |
[title w h init-state tick render] | |
(let [dim (Dimension. w h) | |
keystate (atom #{}) | |
listener (input/listener | |
{:key-pressed (fn [code] | |
(swap! keystate conj code)) | |
:key-released (fn [code] | |
(swap! keystate disj code)) | |
:focus-lost (fn [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def when_let | |
yield self if self | |
end | |
end |