Skip to content

Instantly share code, notes, and snippets.

@st
Created June 26, 2012 17:39
Show Gist options
  • Save st/2997339 to your computer and use it in GitHub Desktop.
Save st/2997339 to your computer and use it in GitHub Desktop.
; Original problem here : http://www.4clojure.com/problem/144
; This first solution works but is incomplete as fs needs to be repeated.
(defn osci-incomplete [v & fs]
(reduce (fn [accu elt] (conj accu (elt (last accu))))
[v] fs))
; Problem is that cycling fs leads to timeout.
(defn osci-timeout [v & fs]
(reduce (fn [accu elt] (conj accu (elt (last accu))))
[v] (cycle fs)))
; I do not understand why.
; Although (cycle fs) is an infinite sequence, which part of the function tries to realize it ?
; ... --- ...
@st
Copy link
Author

st commented Jun 26, 2012

Congrats Max !
It just works and as reductions already shows the intermediate results, conj is no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment