Skip to content

Instantly share code, notes, and snippets.

@visibletrap
Created January 12, 2016 09:02
Show Gist options
  • Save visibletrap/b533d224a9d3c5c99881 to your computer and use it in GitHub Desktop.
Save visibletrap/b533d224a9d3c5c99881 to your computer and use it in GitHub Desktop.
(ns a-namespace
(:require [clojure.string :refer [join]]))
(defn dashes []
(->> (iterate dec 10)
(map #(repeat % "-"))
(map join)))
(defn draw [f]
(->> (map vector (dashes) (f))
(take 10)
(map join)
(map println)))
(defn xes []
(->> (iterate #(+ 2 %) 1)
(map #(repeat % "x"))
(map join)))
(defn gen-inc [c]
(cons (inc (count c)) c))
(defn palindroms []
(map #(str (join %1) (join %2))
(map reverse (iterate gen-inc '(1)))
(iterate gen-inc '())))
(defn some-reverse []
(let [normal (->> (iterate #(+ 4 %) 3)
(map #(take % (iterate inc 1)))
(map join))
reverse (->> (iterate #(+ 4 %) 1)
(map #(take % (iterate inc 1)))
(map reverse)
(map join))]
(interleave reverse normal)))
(draw xes)
(draw palindroms)
(draw some-reverse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment