Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn partition-into [ fnc n seqinput ]
- (let [ a (reverse (sort seqinput)) ]
- (reduce (fn[ cubes val ]
- (let [ ordered-cubes (sort-by #(apply fnc val %1) cubes) ]
- (cons (conj (first ordered-cubes) val) (rest ordered-cubes))))
- (map vector (take n a)) (drop n a) )))
- (partition-into + 5 [ 1 2 34 54 12 23 5 2 3 1 2 12 11 12 32 67 ] )
- ; gives ([32 12 5 1 1] [34 12 2 2] [23 12 11 3 2] [54] [67])
Advertisement
Add Comment
Please, Sign In to add comment