Created
June 26, 2012 17:39
-
-
Save st/2997339 to your computer and use it in GitHub Desktop.
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
; 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 ? | |
; ... --- ... |
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
I expect there is a better way to do it, but this should do.