Created
March 2, 2017 21:29
-
-
Save atroche/5961de498b2d5124045b3bb7dc643a0a to your computer and use it in GitHub Desktop.
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 count-newlines [^bytes barray] | |
(let [num-bytes (alength barray)] | |
(loop [i 0 | |
newlines 0] | |
(if (>= i num-bytes) | |
newlines | |
(if (= 10 (aget ^bytes barray i)) | |
(recur (inc i) | |
(inc newlines)) | |
(recur (inc i) | |
newlines)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment