Created
May 7, 2014 20:00
-
-
Save gilesbowkett/daeefcb6e6bbae18bc5e to your computer and use it in GitHub Desktop.
clojure problem halp pls
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
; given this vector | |
(def probabilities [ 1 0 0 0.5 | |
0 0 1 0 ]) | |
; I want to run (< (rand) probability) against each element | |
; and ultimately get back either | |
(def result [ 0 0.75 1.5 ]) | |
; or | |
(def result [ 0 1.5 ]) | |
; where each row of four, in the above vector, represents row | |
; index + 0, row + 0.25, row + 0.5, row + 0.75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beats my effort, I think:
My result is a vector and not a list, but it's also quite a bit less readable.