Clojure Mentions

2011-07-09 Thread James Estes
I thought some folks on this list might be interested in a mention
graph I put up.  It shows the # mentions of clojure across several
sources (twitter, blogs, etc).

http://twitpic.com/5nm8ve

-- 
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


Re: ordered map in Clojure?

2011-06-25 Thread James Estes
ArrayMap?
http://clojure.org/data_structures#toc21

James


On Sat, Jun 25, 2011 at 1:55 PM, Alex Baranosky
alexander.barano...@gmail.com wrote:
 What are some options for having a map that guarantees ordering of its keys
 in Clojure? (note: sorted-map won't do!)  My first try was to use
 LinkedHashMap, but am running into exceptions of the
  java.util.LinkedHashMap cannot be cast to clojure.lang.Associative
 variety.
 So then I tried to use extend-type LinkedHashMap to Associative.  Then I
 received the error message: interface clojure.lang.Associative is not a
 protocol ... makes sense :)
 So now that I've gone through all of that, which was fun while it lasted,
 could any of you help me figure out how to use a map that guarantees the
 entries are in the order they were entered?
 Thanks for the help!
 Alex

 --
 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 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


Re: last and nth are bad?

2011-06-10 Thread James Estes
Per the doc, last is linear time, and the source doesn't check for reversible.

user= (source last)
(def
 ^{:arglists '([coll])
   :doc Return the last item in coll, in linear time
   :added 1.0}
 last (fn last [s]
(if (next s)
  (recur (next s))
  (first s

unless i'm missing something with multimethod or protocol magic :)



On Thu, Jun 9, 2011 at 10:49 PM, Sunil S Nandihalli
sunil.nandiha...@gmail.com wrote:
 as long as (reversible? of-whatever-collection) is true , last is almost a
 constant time operation

 On Fri, Jun 10, 2011 at 8:20 AM, clojurefanxx neuzhou...@gmail.com wrote:

 i'm a newbie working thru 4clojure.com's problems #19 thru #21 where
 i'm asked to write a function, which when given a list or vector,
 returns the last, penultimate, or an arbitrary nth element,
 respectively.

 for problem #19 (return last element), using the function last was not
 accepted as a good solution for both lists and vectors, but the
 following was accepted:

 user= (#(nth % (- (count %) 1)) '(5 4 3))
 3
 user= (#(nth % (- (count %) 1)) '[1 2 3 4 5])
 5

 for problem #21, (return arbitrary element) , using the function nth
 or get was not accepted.

 -
 Write a function which returns the Nth element from a sequence.

 (= (__ '(4 5 6 7) 2) 6)

 (= (__ [:a :b :c] 0) :a)

 (= (__ [1 2 3 4] 1) 2)

 (= (__ '([1 2] [3 4] [5 6]) 2) [5 6])

 


 i think using the nth or get functions on vectors to return an element
 at index position n should be fine performance-wise,
 but what's a general solution for lists that will perform better than
 O(n)? (i 'm assuming that's the reason why
 last, nth, and get were rejected when I tried them out as candidate
 solutions??)

 thanks for any help!



 --
 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 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 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


Re: last and nth are bad?

2011-06-09 Thread James Estes
I'm fairly new too, but I'll take a stab.  I think the koan's for
19-21 are trying to make you do exactly what you are doing:  consider
the performance characteristics for various operations on a vector vs
a list or sequence.

Problem 19, for example, is highlighting that
1 - Last is slow for a vector.  The last function is really meant to
operate on sequences, and therefore is restricted to only being able
to use first/next in its implementation, so for a vector, it has to
walk the entire vector to get to the end.
2 - Vectors can efficiently get the last value with peek.
So, for 19, it seems to make sense to convert to a vector and just peek:
#(peek (vec %))

For 21, the same is true:  nth is a sequence operation and therefore
must walk the vector.  The solution here is actually what you tried
(use get), but you'd need to convert the lists to a vector first:
#(get (vec %) %2)

So, my lesson learned here is:  If you need random access or, mostly
need access to the end of a fixed-length (ie non-infinite), use, or
convert to a vector.  But, again I'm new too :)

On Thu, Jun 9, 2011 at 8:50 PM, clojurefanxx neuzhou...@gmail.com wrote:
 i'm a newbie working thru 4clojure.com's problems #19 thru #21 where
 i'm asked to write a function, which when given a list or vector,
 returns the last, penultimate, or an arbitrary nth element,
 respectively.

 for problem #19 (return last element), using the function last was not
 accepted as a good solution for both lists and vectors, but the
 following was accepted:

 user= (#(nth % (- (count %) 1)) '(5 4 3))
 3
 user= (#(nth % (- (count %) 1)) '[1 2 3 4 5])
 5

 for problem #21, (return arbitrary element) , using the function nth
 or get was not accepted.
 -
 Write a function which returns the Nth element from a sequence.

 (= (__ '(4 5 6 7) 2) 6)

 (= (__ [:a :b :c] 0) :a)

 (= (__ [1 2 3 4] 1) 2)

 (= (__ '([1 2] [3 4] [5 6]) 2) [5 6])
 


 i think using the nth or get functions on vectors to return an element
 at index position n should be fine performance-wise,
 but what's a general solution for lists that will perform better than
 O(n)? (i 'm assuming that's the reason why
 last, nth, and get were rejected when I tried them out as candidate
 solutions??)

 thanks for any help!



 --
 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 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


Re: library or namespace doc helper function from repl?

2011-06-02 Thread James Estes
You could also try
(find-doc libname)

On Thu, Jun 2, 2011 at 11:15 AM, Alex Robbins
alexander.j.robb...@gmail.com wrote:
 (ns-publics 'namespace) will show all the publicly defined things in a
 namespace.

 On Thu, Jun 2, 2011 at 11:51 AM, Avram aav...@me.com wrote:

 Apologies for a silly question, there must be a simple way to do this
 from the repl, but I can't seem to find it…

 Is there a way from the repl to view all available functions in the
 library or namespace?

 It often happens that I know a library contains functionality I seek,
 but I don't yet know the name.  I realize that I can try to use the
 Atlas url (which is awesome) or an IDE or check github, but it would
 be really nice not to have to leave the repl.
 In R I would do:  library(help=libname)


 Thanks in advance,
 Avram

 --
 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 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 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