<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>82957</integer>
    </number>
    <user>
      <string>AWizzArd</string>
    </user>
    <title>
      <string>How to group/split contents of a collection into groups?</string>
    </title>
    <contents>
      <string>;;; Nice would be something like
;;; (split-when (= % :x) [1 2 3 4 :x 5 6 7 8 :x 9 10 :x 11] ==&gt;
;;; ((1 2 3 4) (:x) (5 6 7 8) (:x) (9 10) (:x) (11))
;;;
;;; How to do this easier than:

(use 'clojure.contrib.seq-utils)

(let [group (atom 1), old (atom true)]
  (group-by #(if (= % :x)
	       (do
		 (reset! old false)
		 (swap! group inc))
	       (if @old
		 @group
		 (do
		   (reset! old true)
		   (swap! group inc))))
	    [1 2 3 4 :x 5 6 7 8 :x 9 10 :x 11]))

;;; ?
;;; While this is not exactly the same result as above
;;; but the data format comes close.</string>
    </contents>
    <universal-time>
      <integer>3455623950</integer>
    </universal-time>
    <channel>
      <string>#clojure</string>
    </channel>
    <colorization-mode>
      <string>Common Lisp</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
    <deletion-requested>
      <null/>
    </deletion-requested>
    <deletion-requested-email>
      <null/>
    </deletion-requested-email>
    <expiration-time>
      <null/>
    </expiration-time>
  </paste>
</paste-with-annotations>
