Created
September 25, 2011 18:27
-
-
Save djhworld/1240932 to your computer and use it in GitHub Desktop.
useful haskell functions that I can't seem to find in clojure
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 group [xs] | |
"splits its sequence argument into a list of lists of equal, adjacent elements." | |
(partition-by identity xs)) | |
(defn zip [xs ys] | |
"makes a list of vector tuples, each tuple containing elements of both sequences occuring at the same position" | |
(map vector xs ys)) | |
(defn lines [str] | |
"For a given string, split it into a vector using a newline terminator as a delimiter" | |
(clojure.string/split-lines str)) | |
(defn words [str] | |
"For a given string, split it into a vector of strings using whitespace as a delimiter" | |
(clojure.string/split str #" " )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment