On Dec 14, 2:22 am, Alan Malloy wrote:
> On Dec 14, 1:18 am, Cedric Greevey wrote:
>
>
>
>
>
>
>
>
>
> > On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy wrote:
> > > On Dec 13, 8:37 pm, Cedric Greevey wrote:
> > >> On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote:
> > >> > On Dec 13, 7:56 pm,
On Dec 14, 1:18 am, Cedric Greevey wrote:
> On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy wrote:
> > On Dec 13, 8:37 pm, Cedric Greevey wrote:
> >> On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote:
> >> > On Dec 13, 7:56 pm, Stephen Compall wrote:
> >> >> On Tue, 2011-12-13 at 16:28 -0800, A
On Wed, Dec 14, 2011 at 3:12 AM, Alan Malloy wrote:
> On Dec 13, 8:37 pm, Cedric Greevey wrote:
>> On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote:
>> > On Dec 13, 7:56 pm, Stephen Compall wrote:
>> >> On Tue, 2011-12-13 at 16:28 -0800, Alan Malloy wrote:
>> >> > As you can see, only as man
On Dec 13, 8:37 pm, Cedric Greevey wrote:
> On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote:
> > On Dec 13, 7:56 pm, Stephen Compall 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
On Tue, Dec 13, 2011 at 11:25 PM, Alan Malloy wrote:
> On Dec 13, 7:56 pm, Stephen Compall 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 (
On Dec 13, 7:56 pm, Stephen Compall 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
> lazy-seqs implied by
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, 3:05 pm, Stephen Compall 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 now stick w
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 (c
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) ite
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 p
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 fing
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,
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 yo
Is there something like:
(defn snoc[ col item ]
(lazy-seq
(if (seq col)
(let[ [f & r] col ]
(if (seq r)
(cons f (snoc r item))
(cons f [i
15 matches
Mail list logo