Skip to content

Instantly share code, notes, and snippets.

@ocanbascil
ocanbascil / clojure-markov.clj
Created August 25, 2015 20:38
Clojure Dojo London, August 25 2015, Simple Markov Chain
(require '[clojure.string :as str])
(def test-tweets [
"Saturday night is all right for sonnets."
"530 years ago today, Richard III tried to trade his kingdom for a horse. Turned out stock in his kingdom had dropped below mule.'"
"I never stay in London during August. Tis plague season."
"Nay, Falstaff doth not overeat. That is not where the calories come from."
"If you ask Polonius a question, you deserve the answer you get."
"Tragedy, for me, is when the best actress in a generation has his voice change."
"Fancy costumes, not much plot, cheesy moral tacked on at the end: superhero movies are just court masques."
@ocanbascil
ocanbascil / gist:c04d108d1df1c1875d46
Created November 26, 2014 14:46
Clojure Dojo London, 24th Nov 2014, 4clojure
;;http://www.4clojure.com/problem/144
;;Write an oscillating iterate: a function that takes an initial value and
;;a variable number of functions. It should return a lazy sequence of the
;;functions applied to the value in order, restarting from the first function after it hits the end.
(fn [n & funcs] (reductions #(%2 %1) n (cycle funcs)))
;;http://www.4clojure.com/problem/110
;;Write a function that returns a lazy sequence of "pronunciations" of a sequence of numbers.
;;A pronunciation of each element in the sequence consists of the number of repeating identical