Re: unconditional append to end

2014-02-10 Thread Alan Thompson
Thank you for the cheat sheet refs.  Definitely helpful.

Anybody have any insight into the current state of clojuredocs.org?
Alan


On Sun, Feb 9, 2014 at 9:38 PM, mynomoto mynom...@gmail.com wrote:

 +1 to the Cheat Sheet although I prefer this version:
 http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html

 After you go though the cheat sheet you can try
 http://clojure.github.io/clojure
 It's more complete but way less nice.


 On Monday, February 10, 2014 3:21:16 AM UTC-2, Mars0i wrote:

 On Sunday, February 9, 2014 10:45:04 PM UTC-6, Alan Thompson wrote:

 ...
 I saw an email a while back that claimed ClojureDocs.org is working on a
 re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the
 meantime, is there a better way of exploring the API?


 Not a full answer, but I get a lot of mileage from the cheatsheet:
 http://clojure.org/cheatsheethttp://www.google.com/url?q=http%3A%2F%2Fclojure.org%2Fcheatsheetsa=Dsntz=1usg=AFQjCNHFa1Bf-ol_ynMqIARWPVgJ-VfYXA

  --
 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 posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-10 Thread t x
Someone needs to make a flappy bird version of
http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html

It provides a description of the function, you type in the function name. :-)

On Mon, Feb 10, 2014 at 8:22 AM, Alan Thompson thompson2...@gmail.com wrote:
 Thank you for the cheat sheet refs.  Definitely helpful.

 Anybody have any insight into the current state of clojuredocs.org?
 Alan


 On Sun, Feb 9, 2014 at 9:38 PM, mynomoto mynom...@gmail.com wrote:

 +1 to the Cheat Sheet although I prefer this version:
 http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html

 After you go though the cheat sheet you can try
 http://clojure.github.io/clojure
 It's more complete but way less nice.


 On Monday, February 10, 2014 3:21:16 AM UTC-2, Mars0i wrote:

 On Sunday, February 9, 2014 10:45:04 PM UTC-6, Alan Thompson wrote:

 ...
 I saw an email a while back that claimed ClojureDocs.org is working on a
 re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the
 meantime, is there a better way of exploring the API?


 Not a full answer, but I get a lot of mileage from the cheatsheet:
 http://clojure.org/cheatsheet

 --
 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 posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


 --
 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 posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-10 Thread mynomoto
You can see the project of the new clojuredocs.org 
on https://github.com/clojuredocs/web

There is discussion about clojuredocs.org 
here https://groups.google.com/d/msg/clojure/jWMaop_eVaQ/I-H4Fn1brVcJ

But I don't know about the current status.

Marcelo

On Monday, February 10, 2014 2:22:04 PM UTC-2, Alan Thompson wrote:

 Thank you for the cheat sheet refs.  Definitely helpful.

 Anybody have any insight into the current state of clojuredocs.org?
 Alan


 On Sun, Feb 9, 2014 at 9:38 PM, mynomoto myno...@gmail.com 
 javascript:wrote:

 +1 to the Cheat Sheet although I prefer this version: 
 http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html

 After you go though the cheat sheet you can try 
 http://clojure.github.io/clojure
 It's more complete but way less nice.


 On Monday, February 10, 2014 3:21:16 AM UTC-2, Mars0i wrote:

 On Sunday, February 9, 2014 10:45:04 PM UTC-6, Alan Thompson wrote:

 ...
 I saw an email a while back that claimed ClojureDocs.org is working on 
 a re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the 
 meantime, is there a better way of exploring the API?


 Not a full answer, but I get a lot of mileage from the cheatsheet: 
 http://clojure.org/cheatsheethttp://www.google.com/url?q=http%3A%2F%2Fclojure.org%2Fcheatsheetsa=Dsntz=1usg=AFQjCNHFa1Bf-ol_ynMqIARWPVgJ-VfYXA
  

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-10 Thread Stuart Sierra
On Friday, February 7, 2014 7:20:09 PM UTC-5, t x wrote:
 Thus, my question: is there a builtin to _unconditinoally_
 append to the end of a list/sequence/vector?

Not built in.

If you want things to grow at the end, you probably want vectors anyway. So 
try this:

  (defn conjv [coll item]
(conj (vec coll) item))

-S

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-10 Thread Mars0i


On Monday, February 10, 2014 11:56:18 AM UTC-6, t x wrote:

 Someone needs to make a flappy bird version of 

 http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html
  

 It provides a description of the function, you type in the function name. 
 :-) 


Like this? :

~$ clojure
user= (doc conj)
-
clojure.core/conj
([coll x] [coll x  xs])
  conj[oin]. Returns a new collection with the xs
'added'. (conj nil item) returns (item).  The 'addition' may
happen at different 'places' depending on the concrete type.
nil
user= 

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-10 Thread Mars0i


On Sunday, February 9, 2014 11:38:39 PM UTC-6, mynomoto wrote:

 +1 to the Cheat Sheet although I prefer this version: 
 http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html


Several variations on the cheatsheet are available via links from the main 
cheatsheet page http://clojure.org/cheatsheet, including that one, btw. 

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-10 Thread Sean Corfield
I find clojureatlas.com very helpful for exploring the API, especially since it 
is concept-based (so Maps is a concept that shows all the related functions 
and concepts).

It's only up to 1.4.0 - hopefully Chas will update it to 1.5 / 1.6 at some 
point - but it's better than a site stuck at 1.2...

Sean

On Feb 9, 2014, at 8:45 PM, Alan Thompson thompson2...@gmail.com wrote:

 Holy cow!  Where have these been hiding!  They don't show up on 
 ClojureDocs.org at all!!!  I was about to write my own macro vmap to 
 implement (vec (map(...)) for just the use cases outlined above.
 
 I just looked on clojure.org, and searching on map doesn't return any 
 (useful) results.  I eventually found it alphabetically on a sub-page in the 
 API area.
 
 I saw an email a while back that claimed ClojureDocs.org is working on a 
 re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the 
 meantime, is there a better way of exploring the API?
 
 Alan
 
 
 
 On Sat, Feb 8, 2014 at 1:44 AM, mynomoto mynom...@gmail.com wrote:
 Maybe you could use mapv and filterv? This way you will always get a vector 
 and conj apends in the end.
 



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: unconditional append to end

2014-02-09 Thread Alan Thompson
Holy cow!  Where have these been hiding!  They don't show up on
ClojureDocs.org at all!!!  I was about to write my own macro vmap to
implement (vec (map(...)) for just the use cases outlined above.

I just looked on clojure.org, and searching on map doesn't return any
(useful) results.  I eventually found it alphabetically on a sub-page in
the API area.

I saw an email a while back that claimed ClojureDocs.org is working on a
re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the
meantime, is there a better way of exploring the API?

Alan



On Sat, Feb 8, 2014 at 1:44 AM, mynomoto mynom...@gmail.com wrote:

 Maybe you could use mapv and filterv? This way you will always get a
 vector and conj apends in the end.


 On Friday, February 7, 2014 10:20:09 PM UTC-2, t x wrote:

 Consider the following:

 (cons 1 '(2 3 4)) == (1 2 3 4)
 (cons 1 [2 3 4])  == (1 2 3 4)

 (conj '(a b c) 1) == (1 a b c)
 (conj '[a b c] 1) == [a b c 1]


 

 Now, I would like something that _always_
   * appends to the end

 cons is almost what I want, except it always appends to front.

 conj is not what I want -- in fact, I'm afraid of conj. Often times,
 I'll run map/filter on something, and suddenly, instead of a vector, I
 now have a list -- and conj changes the order of the item added.

 Thus, my question: is there a builtin to _unconditinoally_ append to
 the end of a list/sequence/vector?

 Thanks!

  --
 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 posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-09 Thread Mars0i
On Sunday, February 9, 2014 10:45:04 PM UTC-6, Alan Thompson wrote:

 ...
 I saw an email a while back that claimed ClojureDocs.org is working on a 
 re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the 
 meantime, is there a better way of exploring the API?


Not a full answer, but I get a lot of mileage from the cheatsheet: 
http://clojure.org/cheatsheet 

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-09 Thread mynomoto
+1 to the Cheat Sheet although I prefer this 
version: 
http://jafingerhut.github.io/cheatsheet-clj-1.3/cheatsheet-tiptip-cdocs-summary.html

After you go though the cheat sheet you can try 
http://clojure.github.io/clojure
It's more complete but way less nice.

On Monday, February 10, 2014 3:21:16 AM UTC-2, Mars0i wrote:

 On Sunday, February 9, 2014 10:45:04 PM UTC-6, Alan Thompson wrote:

 ...
 I saw an email a while back that claimed ClojureDocs.org is working on a 
 re-write of the site, and an upgrade from Clojure 1.2 to 1.5.  In the 
 meantime, is there a better way of exploring the API?


 Not a full answer, but I get a lot of mileage from the cheatsheet: 
 http://clojure.org/cheatsheethttp://www.google.com/url?q=http%3A%2F%2Fclojure.org%2Fcheatsheetsa=Dsntz=1usg=AFQjCNHFa1Bf-ol_ynMqIARWPVgJ-VfYXA
  


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-08 Thread mynomoto
Maybe you could use mapv and filterv? This way you will always get a vector 
and conj apends in the end.

On Friday, February 7, 2014 10:20:09 PM UTC-2, t x wrote:

 Consider the following: 

 (cons 1 '(2 3 4)) == (1 2 3 4) 
 (cons 1 [2 3 4])  == (1 2 3 4) 

 (conj '(a b c) 1) == (1 a b c) 
 (conj '[a b c] 1) == [a b c 1] 


  

 Now, I would like something that _always_ 
   * appends to the end 

 cons is almost what I want, except it always appends to front. 

 conj is not what I want -- in fact, I'm afraid of conj. Often times, 
 I'll run map/filter on something, and suddenly, instead of a vector, I 
 now have a list -- and conj changes the order of the item added. 

 Thus, my question: is there a builtin to _unconditinoally_ append to 
 the end of a list/sequence/vector? 

 Thanks! 


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-08 Thread Gary Verhaegen
Or use vec to turn a sequence into a vector.

As a general comment, using a dynamically typed language should not be seen
as an opportunity not to think about types. You should still design your
functions, think about the types they should receive, etc. Not having the
compiler to check it for you actually places more burden on yourself and
your self-discipline. You're basically taking responsibility for type
checking in your head, in exchange for less (keyboard) typing and more
flexibility.

Generally speaking, people complaining about conj makes me wonder if they
see the above tradeoff in the same light as I do.


On 8 February 2014 10:44, mynomoto mynom...@gmail.com wrote:

 Maybe you could use mapv and filterv? This way you will always get a
 vector and conj apends in the end.


 On Friday, February 7, 2014 10:20:09 PM UTC-2, t x wrote:

 Consider the following:

 (cons 1 '(2 3 4)) == (1 2 3 4)
 (cons 1 [2 3 4])  == (1 2 3 4)

 (conj '(a b c) 1) == (1 a b c)
 (conj '[a b c] 1) == [a b c 1]


 

 Now, I would like something that _always_
   * appends to the end

 cons is almost what I want, except it always appends to front.

 conj is not what I want -- in fact, I'm afraid of conj. Often times,
 I'll run map/filter on something, and suddenly, instead of a vector, I
 now have a list -- and conj changes the order of the item added.

 Thus, my question: is there a builtin to _unconditinoally_ append to
 the end of a list/sequence/vector?

 Thanks!

  --
 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 posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


unconditional append to end

2014-02-07 Thread t x
Consider the following:

(cons 1 '(2 3 4)) == (1 2 3 4)
(cons 1 [2 3 4])  == (1 2 3 4)

(conj '(a b c) 1) == (1 a b c)
(conj '[a b c] 1) == [a b c 1]




Now, I would like something that _always_
  * appends to the end

cons is almost what I want, except it always appends to front.

conj is not what I want -- in fact, I'm afraid of conj. Often times,
I'll run map/filter on something, and suddenly, instead of a vector, I
now have a list -- and conj changes the order of the item added.

Thus, my question: is there a builtin to _unconditinoally_ append to
the end of a list/sequence/vector?

Thanks!

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-07 Thread Armando Blancas
For efficient appends at the end you need a vector. Using the sequence 
library can be tricky while you're putting together your data structures 
because it's likely that you'll not done yet with type-specific functions. 
You'll need to re-create your vector after using map/filter/etc to be able 
to keep adding at the end. 

On Friday, February 7, 2014 4:20:09 PM UTC-8, t x wrote:

 Consider the following: 

 (cons 1 '(2 3 4)) == (1 2 3 4) 
 (cons 1 [2 3 4])  == (1 2 3 4) 

 (conj '(a b c) 1) == (1 a b c) 
 (conj '[a b c] 1) == [a b c 1] 


  

 Now, I would like something that _always_ 
   * appends to the end 

 cons is almost what I want, except it always appends to front. 

 conj is not what I want -- in fact, I'm afraid of conj. Often times, 
 I'll run map/filter on something, and suddenly, instead of a vector, I 
 now have a list -- and conj changes the order of the item added. 

 Thus, my question: is there a builtin to _unconditinoally_ append to 
 the end of a list/sequence/vector? 

 Thanks! 


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-07 Thread Travis Moy
You should use a vector, but it's also possible to use concat. For example, 
(concat '(1 2 3) [4]) will give you (1 2 3 4).

This made me curious as to the best way to get a collection into vector, so 
I played around with it some:

user= (def r 10)
 #'user/r
 user= (def coll (range 1))
 #'user/coll
 user= (def coll-v (into [] coll))
 #'user/coll-v
 user= (time (dotimes [_ r] (conj (into [] coll) :a)))
 Elapsed time: 14074.018464 msecs
 nil
 user= (time (dotimes [_ r] (conj (apply vector coll) :a)))
 Elapsed time: 22565.594515 msecs
 nil
 user= (time (dotimes [_ r] (conj (vec coll) :a)))
 Elapsed time: 22424.174719 msecs
 nil
 user= (time (dotimes [_ r] (concat coll '(:a
 Elapsed time: 5.366059 msecs
 nil
 user= (time (dotimes [_ r] (concat coll-v '(:a
 Elapsed time: 5.56465 msecs
 nil
 user= (time (dotimes [_ r] (conj coll-v :a)))
 Elapsed time: 10.65771 msecs
 nil
 user= (time (dotimes [_ r] (concat coll coll)))
 Elapsed time: 6.048041 msecs
 nil
 user= (time (dotimes [_ r] (apply conj coll-v coll-v)))
 Elapsed time: 72414.847105 msecs
 nil


Surprisingly it looks like (concat coll '(:a)) is faster than (conj coll-v 
:a). That's not really what I would expect; does anybody have a good 
explanation for this? Did I just bork the test somehow, or - I mean, 
obviously concat's pretty fast but I was expecting conj to be on the level. 
In fact, if you convert and then conj it's significantly slower than using 
concat.

...not that it'd really matter, in basically all cases, since (into [] ...) 
is definitely still in the fast enough category. Still, if you're 
building a sequence, what's the reasoning against using (concat coll ...) 
instead of (conj (into [] ...) ...)? Is it a matter of elegance, or is 
there a specific practical reason?

On Friday, February 7, 2014 8:06:20 PM UTC-8, Armando Blancas wrote:

 For efficient appends at the end you need a vector. Using the sequence 
 library can be tricky while you're putting together your data structures 
 because it's likely that you'll not done yet with type-specific functions. 
 You'll need to re-create your vector after using map/filter/etc to be able 
 to keep adding at the end. 

 On Friday, February 7, 2014 4:20:09 PM UTC-8, t x wrote:

 Consider the following: 

 (cons 1 '(2 3 4)) == (1 2 3 4) 
 (cons 1 [2 3 4])  == (1 2 3 4) 

 (conj '(a b c) 1) == (1 a b c) 
 (conj '[a b c] 1) == [a b c 1] 


  

 Now, I would like something that _always_ 
   * appends to the end 

 cons is almost what I want, except it always appends to front. 

 conj is not what I want -- in fact, I'm afraid of conj. Often times, 
 I'll run map/filter on something, and suddenly, instead of a vector, I 
 now have a list -- and conj changes the order of the item added. 

 Thus, my question: is there a builtin to _unconditinoally_ append to 
 the end of a list/sequence/vector? 

 Thanks! 



-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-07 Thread Mark Engelberg
On Fri, Feb 7, 2014 at 9:08 PM, Travis Moy moytra...@gmail.com wrote:

 Surprisingly it looks like (concat coll '(:a)) is faster than (conj coll-v
 :a). That's not really what I would expect; does anybody have a good
 explanation for this? Did I just bork the test somehow, or - I mean,
 obviously concat's pretty fast but I was expecting conj to be on the level.
 In fact, if you convert and then conj it's significantly slower than using
 concat.


concat is lazy, so it's not really doing any work until you try to realize
the sequence -- that's why it is so fast.

-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unconditional append to end

2014-02-07 Thread Travis Moy
Ah! That makes more sense. Yeah, after I forced it to realize the sequence, 
it turned out that concat was a lot slower than sticking it into an array:

#'user/r
 user= (def coll (range 1))
 #'user/coll
 user= (def coll-v (into [] coll))
 #'user/coll-v
 user= (time (dotimes [_ r] (count (concat coll '(:a)
 Elapsed time: 55803.147526 msecs
 nil
 user= (time (dotimes [_ r] (count (conj coll-v :a
 Elapsed time: 18.591737 msecs
 nil
 user= (time (dotimes [_ r] (count (conj (into [] coll) :a
 Elapsed time: 16224.79319 msecs
 nil


On Friday, February 7, 2014 9:26:05 PM UTC-8, puzzler wrote:

 On Fri, Feb 7, 2014 at 9:08 PM, Travis Moy moyt...@gmail.comjavascript:
  wrote:

 Surprisingly it looks like (concat coll '(:a)) is faster than (conj 
 coll-v :a). That's not really what I would expect; does anybody have a good 
 explanation for this? Did I just bork the test somehow, or - I mean, 
 obviously concat's pretty fast but I was expecting conj to be on the level. 
 In fact, if you convert and then conj it's significantly slower than using 
 concat.


 concat is lazy, so it's not really doing any work until you try to realize 
 the sequence -- that's why it is so fast. 


-- 
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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.