Skip to content

Instantly share code, notes, and snippets.

@rplevy
Created April 17, 2012 17:13
Show Gist options
  • Save rplevy/2407570 to your computer and use it in GitHub Desktop.
Save rplevy/2407570 to your computer and use it in GitHub Desktop.
trystero furcula use case
(ns example
(:require [clojure-csv.core :as csv]
[swiss-arrows.core :refer [-<<]]))
(let [[headers rows]
((juxt (partial take 4)
(partial drop 4))
(csv/parse-csv (slurp csv-file))))]
,,,)
;; versus
(let [[headers rows]
(-<< (csv/parse-csv (slurp csv-file))
(take 4)
(drop 4))]
,,,)
;; the above is a bit artificial because split-at exists in core, but the point is about the more general case of reducing awkward juxts
;; and meaningless temporary lexical bindings
;; another example
(let [[foo bar] (-<>< [[1 2] [3 4] [5 6] [7 8] [9 10]]
(->> <> (take 2) flatten)
(drop 2 <>))]
[foo bar])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment