This file contains hidden or 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
(defn sample-mr [l] | |
(reduce (fn [x [y i]] (if (< (/ i (inc i)) (rand)) y x)) | |
nil | |
(map vector l (iterate inc 0)))) |
This file contains hidden or 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
(defn remove-curlied | |
[^String text] | |
(let [sb (StringBuilder.) | |
end (int (count text))] | |
(loop [state (int 0) | |
pos (int 0)] | |
(cond | |
(= pos end) (.toString sb) | |
(= (int (.charAt text pos)) (int \{)) (recur (inc state) (inc pos)) | |
(= (int (.charAt text pos)) (int \})) (recur (dec state) (inc pos)) |