On Dec 13, 8:37 pm, Cedric Greevey cgree...@gmail.com wrote:
On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 7:56 pm, Stephen Compall stephen.comp...@gmail.com wrote:
On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote:
As you can see, only as many
On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 8:37 pm, Cedric Greevey cgree...@gmail.com wrote:
On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 7:56 pm, Stephen Compall stephen.comp...@gmail.com wrote:
On Tue, 2011-12-13 at
On Dec 14, 1:18 am, Cedric Greevey cgree...@gmail.com wrote:
On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 8:37 pm, Cedric Greevey cgree...@gmail.com wrote:
On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 7:56 pm, Stephen
On Dec 14, 2:22 am, Alan Malloy a...@malloys.org wrote:
On Dec 14, 1:18 am, Cedric Greevey cgree...@gmail.com wrote:
On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 8:37 pm, Cedric Greevey cgree...@gmail.com wrote:
On Tue, Dec 13, 2011 at 11:25 PM,
On Mon, 2011-12-12 at 10:53 -0800, Michael Jaaka wrote:
(defn conr[ col item ]
(lazy-seq
(if (seq col)
(cons (first col) (conr (rest col) item))
(list item
And now stick with it.
All works as desired:
(conr (conr (conr
On Dec 13, 3:05 pm, Stephen Compall stephen.comp...@gmail.com wrote:
On Mon, 2011-12-12 at 10:53 -0800, Michael Jaaka wrote:
(defn conr[ col item ]
(lazy-seq
(if (seq col)
(cons (first col) (conr (rest col) item))
(list item
And
On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote:
As you can see, only as many elements are realized as are needed to
satisfy the user's request.
Yes, in the expression (conr (conr (conr '( 1 2 3) 4) 6) 7), all the
lazy-seqs implied by the conr calls must be forced immediately to yield
(1 .
On Dec 13, 7:56 pm, Stephen Compall stephen.comp...@gmail.com wrote:
On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote:
As you can see, only as many elements are realized as are needed to
satisfy the user's request.
Yes, in the expression (conr (conr (conr '( 1 2 3) 4) 6) 7), all the
On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy a...@malloys.org wrote:
On Dec 13, 7:56 pm, Stephen Compall stephen.comp...@gmail.com wrote:
On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote:
As you can see, only as many elements are realized as are needed to
satisfy the user's request.
Thanks to all for responses.
I just wanted to use that in higher-order composition in mind, not to
construct any data structures.
I have tweaked a bit the function:
(defn conr[ col item ]
(lazy-seq
(if (seq col)
(cons (first col) (conr (rest col)
Hi,
total newbie here but what about conj?
(conj (conj (conj [ 1 2 3] 4) 6) 7)
would return
[1 2 3 4 6 7]
--
Marco Abis
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that
conj adds an element to a data structure in a place most efficient for the
particular type of data structure. For lists, this is at the beginning.
For vectors, it is at the end:
user= (conj (conj (conj '(1 2 3) 4) 6) 7)
(7 6 4 1 2 3)
user= (conj (conj (conj [1 2 3] 4) 6) 7)
[1 2 3 4 6 7]
If you
Conj (http://clojuredocs.org/clojure_core/clojure.core/conj) does what
you need for vectors. It's behavior depends on the type of collection
passed, so if you did:
(conj '(1 2 3) 4) you would end up with '(4 1 2 3).
For vectors it appends to the end of the list, for lists the beginning.
On Sat,
I forgot to mention, if you want a Clojure persistent data structure that
is efficient (O(1) or O(log n)) for all of these operations:
+ adding to/removing from beginning
+ adding to/removing from end
+ concatenating
+ splitting into two sequences, at any specified item in the middle
look at
14 matches
Mail list logo