Skip to content

Instantly share code, notes, and snippets.

@msgodf
Created April 10, 2013 08:03
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 msgodf/5352711 to your computer and use it in GitHub Desktop.
Save msgodf/5352711 to your computer and use it in GitHub Desktop.
Several attempts to get a sweet solution to getting digit parcel part of Brian Marick's Brisfunctional talk.
user=> (map #(partition 3 %) ["123---" "456---"])
(((\1 \2 \3) (\- \- \-)) ((\4 \5 \6) (\- \- \-)))
user=> (map #(map (partial apply str) (partition 3 %)) ["123---" "456---"])
(("123" "---") ("456" "---"))
user=> (map #(map (partial apply str) (partition 3 %)) s) ["123---" "456---"])
CompilerException java.lang.RuntimeException: Unable to resolve symbol: s in this context, compiling:(NO_SOURCE_PATH:1:1)
["123---" "456---"]
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:219)
user=> (map #(map (partial vec str) (partition 3 %)) ["123---" "456---"])
ArityException Wrong number of args (2) passed to: core$vec clojure.lang.AFn.throwArity (AFn.java:437)
user=> (map #(map (partial apply str) (partition 3 %)) ["123---" "456---"])
(("123" "---") ("456" "---"))
user=> (map #(map (fn [s] (apply str s)) (partition 3 %)) ["123---" "456---"])
(("123" "---") ("456" "---"))
user=> (map #(map (fn [s] (first (apply str s))) (partition 3 %)) ["123---" "456---"])
((\1 \-) (\4 \-))
user=> (map #(map (fn [s] (apply str s)) (partition 3 %)) ["123---" "456---"])
(("123" "---") ("456" "---"))
user=> (map (fn [& xs] (apply map (fn [&ys] (apply list ys)) xs)) (partition 3 %)) ["123---" "456---"])
CompilerException java.lang.RuntimeException: Unable to resolve symbol: ys in this context, compiling:(NO_SOURCE_PATH:1:38)
["123---" "456---"]
RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:219)
user=> (map (fn [& xs] (apply map (fn [&ys] (apply list ys)) xs) (partition 3 %)) ["123---" "456---"])
CompilerException java.lang.RuntimeException: Unable to resolve symbol: ys in this context, compiling:(NO_SOURCE_PATH:1:38)
user=> (map (fn [& xs] (apply map (fn [& ys] (apply list ys)) xs) (partition 3 %)) ["123---" "456---"])
CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:1:60)
user=> (map (fn [& xs] (apply map (fn [& ys] (apply list ys)) (partition 3 xs))) ["123---" "456---"])
ArityException Wrong number of args (1) passed to: core$map clojure.lang.AFn.throwArity (AFn.java:437)
user=> (map (fn [& xs] (apply (partial map (fn [& ys] (apply list ys))) (partition 3 xs))) ["123---" "456---"])
ArityException Wrong number of args (1) passed to: core$map clojure.lang.AFn.throwArity (AFn.java:437)
user=> (map (fn [& xs] (apply (partial map (fn [& ys] (apply list ys))) (partition 3 xs))) ["123---" "456---"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment