Skip to content

Instantly share code, notes, and snippets.

@kohyama kohyama/map-between.clj
Last active Oct 19, 2017

Embed
What would you like to do?
apply a function to an element and the next element of it in a sequence
(require '[clojure.test :refer (with-test are run-tests)])
(with-test
(defn map-between [f s]
(map (fn [[a b]] (f a b)) (partition 2 1 s)))
(are [f s _ r] (= (map-between f s) r)
#(- %2 %1) '() -> '()
#(- %2 %1) '(0) -> '()
#(- %2 %1) '(0 1) -> '(1)
#(- %2 %1) '(0 1 4) -> '(1 3)
#(- %2 %1) '(0 1 4 9) -> '(1 3 5)))
@kohyama

This comment has been minimized.

Copy link
Owner Author

commented Jul 25, 2013

元ネタはこちら

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.