Changes for clojure.core/vector

jafingerhut on Tue, 13 Mar 2012
;; Destructuring with a vector, inside a "let" form, more complex cases:

user=> (let [[first-element second-element & the-rest] my-vector] 
         (str "first=" first-element " second=" second-element " 
           the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how "the-rest" is a sequence

user=> (let [[first-element second-element third-element fourth-element 
               :as everything] 
             my-vector] 
         (str "first=" first-element " second=" second-element " 
           third=" third-element " fourth=" fourth-element " 
           everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notice how "everything" is the whole vector
belun on Tue, 28 Sep 2010
;; Destructuring with a vector, inside a "let" form, more complex cases:

user=> (let [[first-element second-element & the-rest] my-vector] 
         (str "first=" first-element " second=" second-element " 
           the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how "the-rest" symbol points to a list

user=> (let [[first-element second-element third-element fourth-element 
               :as everything] 
             my-vector] 
         (str "first=" first-element " second=" second-element " 
           third=" third-element " fourth=" fourth-element " 
           everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notice how the "everything" symbol points to the hole vector
belun on Tue, 28 Sep 2010
;; Destructuring with a vector, inside a "let" form, more complex cases:

user=> (let [[first-element second-element & the-rest] my-vector] 
         (str "first=" first-element " second=" second-element " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how "the-rest" symbol points to a list

user=> (let [[first-element second-element third-element fourth-element 
               :as everything] 
             my-vector] 
         (str "first=" first-element " second=" second-element " 
           third=" third-element " fourth=" fourth-element " 
           everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notice how the "everything" symbol points to the hole vector
zkim on Sun, 26 Sep 2010
;; Destructuring with a vector, inside a "let" form, more complex cases:

user=> (let [[first second & the-rest] my-vector] 
         (str "first=" first " second=" second " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how "the-rest" symbol points to a list

user=> (let [[first second third fourth :as everything] my-vector] 
         (str "first=" first " second=" second " third="third " 
     fourth=" fourth " everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notice how the "everything" symbol points to the hole vector
zkim on Sun, 26 Sep 2010
;; Destructuring with a vector, inside a "let" form, more complex cases:

user=> (let [[first second & the-rest] my-vector] 
         (str "first=" first " second=" second " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how "the-rest" symbol points to a list

user=> (let [[first second third fourth :as everything] my-vector] 
         (str "first=" first " second=" second " third="third " 
     fourth=" fourth " everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notive how the "everything" symbol points to the hole vector
belun on Sun, 26 Sep 2010
;; Destructuring with a vector, inside a "let" form, more complex cases:

(let [[first second & the-rest] my-vector] 
  (str "first=" first " second=" second " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how "the-rest" symbol points to a list

user=> (let [[first second third fourth :as everything] my-vector] 
  (str "first=" first " second=" second " third="third " 
     fourth=" fourth " everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notive how the "everything" symbol points to the hole vector
belun on Sun, 26 Sep 2010
;; Destructuring with a vector, inside a "let" form, more complex cases:

(let [[first second & the-rest] my-vector] 
  (str "first=" first " second=" second " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how the-rest symbol points to a list

user=> (let [[first second third fourth :as everything] my-vector] 
  (str "first=" first " second=" second " third="third " 
     fourth=" fourth " everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notive how the "everything" symbol points to the hole vector
belun on Sun, 26 Sep 2010
Destructuring with a vector, inside a "let" form, more complex cases:

(let [[first second & the-rest] my-vector] 
  (str "first=" first " second=" second " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how the-rest symbol points to a list

user=> (let [[first second third fourth :as everything] my-vector] 
  (str "first=" first " second=" second " third="third " 
     fourth=" fourth " everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notive how the "everything" symbol points to the hole vector
belun on Sun, 26 Sep 2010
Destructuring with a vector, more complex cases:

(let [[first second & the-rest] my-vector] 
  (str "first=" first " second=" second " the-rest=" the-rest))
"first=1 second=2 the-rest=(3 4)"
;; notice how the-rest symbol points to a list

user=> (let [[first second third fourth :as everything] my-vector] 
  (str "first=" first " second=" second " third="third " 
     fourth=" fourth " everything=" everything))
"first=1 second=2 third=3 fourth=4 everything=[1 2 3 4]"
;; notive how the "everything" symbol points to the hole vector