functional approach to algorithm

2012-10-09 Thread Brian Craft
I'm holding a list, say [a b c d e]. I need all the adjacent pairs, like [[a b] [b c] [c d] [d e]]. It's a bit like reduce, but I don't know how to accumulate the result with clojure's reduce. Anyone have a suggestion? -- You received this message because you are subscribed to the Google

Re: functional approach to algorithm

2012-10-09 Thread Ben Wolfson
user (let [x '(a b c d e)] (map vector x (rest x))) ([a b] [b c] [c d] [d e]) On Tue, Oct 9, 2012 at 3:49 PM, Brian Craft craft.br...@gmail.com wrote: I'm holding a list, say [a b c d e]. I need all the adjacent pairs, like [[a b] [b c] [c d] [d e]]. It's a bit like reduce, but I don't know

Re: functional approach to algorithm

2012-10-09 Thread Jonathan Fischer Friberg
(partition 2 1 [a b c d e]) http://clojuredocs.org/clojure_core/clojure.core/partition On Wed, Oct 10, 2012 at 12:49 AM, Brian Craft craft.br...@gmail.com wrote: I'm holding a list, say [a b c d e]. I need all the adjacent pairs, like [[a b] [b c] [c d] [d e]]. It's a bit like reduce, but I

Re: functional approach to algorithm

2012-10-09 Thread Brian Craft
:) Thanks On Tuesday, October 9, 2012 3:55:58 PM UTC-7, Ben wrote: user (let [x '(a b c d e)] (map vector x (rest x))) ([a b] [b c] [c d] [d e]) On Tue, Oct 9, 2012 at 3:49 PM, Brian Craft craft...@gmail.comjavascript: wrote: I'm holding a list, say [a b c d e]. I need all the