Created
October 1, 2017 23:39
-
-
Save dfcarpenter/06f3cd28223061acc7584159dcfcc0fb to your computer and use it in GitHub Desktop.
converting some JS
This file contains 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
getNavStates(indx, length) { | |
let styles = []; | |
for (let i=0; i<length; i++) { | |
if (i < indx) { | |
styles.push('done'); | |
} | |
else if (i === indx) { | |
styles.push('doing'); | |
} | |
else { | |
styles.push('todo'); | |
} | |
} | |
return { current: indx, styles } | |
} | |
(defn getNavStates [idx, length] | |
(let [styles []] | |
(loop [x length] | |
(if (> x length) | |
{:current idx :styles styles} | |
(cond | |
(< x idx) (fn [x] | |
(assoc styles x "done") | |
(recur (inc x))) | |
(= x idx) (fn [x] | |
(assoc styles x "doing") | |
(recur (inc x))) | |
(> x idx) (fn [x] | |
(assoc styles x "todo") | |
(recur (inc x)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment