Skip to content

Instantly share code, notes, and snippets.

@blacktaxi
Forked from djhworld/haskjure.clj
Created January 26, 2012 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blacktaxi/1682844 to your computer and use it in GitHub Desktop.
Save blacktaxi/1682844 to your computer and use it in GitHub Desktop.
useful haskell functions that I can't seem to find in clojure
(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