Skip to content

Instantly share code, notes, and snippets.

@joakin
Last active September 26, 2016 12:06
Show Gist options
  • Save joakin/c5dfc23ce4024881731f69aed6a5093c to your computer and use it in GitHub Desktop.
Save joakin/c5dfc23ce4024881731f69aed6a5093c to your computer and use it in GitHub Desktop.
todos solution
[{:type :input :value
"(def todos [\"Buy milk\"
\"Read newspaper\"
\"Pick up olives\"
\"1h jog\"])"}
{:type :input :value
"(defn todo->str [index todo] (str index \". \" todo \"\\n\"))"}
{:type :input :value
"(defn indexes [ts]
(map inc (range (count ts))))"}
{:type :input :value
"(defn todos->str [ts]
(let [lines (map todo->str (indexes ts) ts)]
(apply str lines)))"}
{:type :input :value "(js/alert (todos->str todos))"}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment