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

Aw: Re: last and nth are bad?

2011-06-10 Thread Meikel Brandmeyer
Hi, Am Freitag, 10. Juni 2011 06:49:41 UTC+2 schrieb Sunil Nandihalli: as long as (reversible? of-whatever-collection) is true , last is almost a constant time operation In theory, but not in practice. last will always be O(N) in it's current implementation. The only fast way to get the

Re: Re: last and nth are bad?

2011-06-10 Thread Sunil S Nandihalli
ah sorry for that.. But it looks like I have grown very complacent about clojure-functions doing the *right thing* .. my bad. Sunil. On Fri, Jun 10, 2011 at 12:06 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am Freitag, 10. Juni 2011 06:49:41 UTC+2 schrieb Sunil Nandihalli: as long as

Re: Using slurp to read changing JSON string

2011-06-10 Thread Ivan Koblik
Hi Thomas, You need to execute this line: (dosync (ref-set location (read-json (slurp url every time you want to re-query the string. To do this periodically you could do something like this [1]: (import '(java.util TimerTask Timer)) (let [task (proxy [TimerTask] [] (run [] (dosync

Re: last and nth are bad?

2011-06-10 Thread clojurefanxx
It seems that when i get messages saying that You tripped the alarm! last is bad! or You tripped the alarm! nth is bad!, I'm merely being told not to use last or nth as the candidate solutions but instead to write my own functions that achieve the same goal. So the messages last is bad! or nth is

Re: last and nth are bad?

2011-06-10 Thread Nick Zbinden
Shouldn't these funkitons take the most effective implementation iternaly? We allready have a internal reduce-protocoll why not have one for other functions like last? The seq library should only drop to first/rest if there is no better implementation. -- You received this message because you

Svar: Re: clojure-contrib.jar file

2011-06-10 Thread Stuart Sierra
Yes, the last monolithic contrib build was 1.3.0-alpha4. It builds with Clojure 1.3.0-alpha4, but not the later alphas. There are 2 combined jars in contrib 1.3.0-alpha4. The standalone module contains all the classes/sources merged into a single JAR file. The complete module contains

Re: Using slurp to read changing JSON string

2011-06-10 Thread Thomas
Hi Ivan et al, I have managed to re-read the string every 15 seconds, the problem is that the slurp reads stale data. It returns always the same string, even though I can see in my browser that it has changed. This also happens when I just do the slurp in the REPL. Apologies for not making this

Singly linked lists as an immutable data structure

2011-06-10 Thread Sam Aaron
Hi there, I've now seen singly linked lists used as a way of describing Clojure's immutable data structures with the claim that they're used to implement lists. The example usually goes as follows. A has the list '(1 2 3) which is implemented as follows: A | | V +---+ +---+

Aw: Singly linked lists as an immutable data structure

2011-06-10 Thread Meikel Brandmeyer
Hi, yes. C has to copy the whole list and prepend its element to the element she wants to add at the end. Lists are bad at appending. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Using slurp to read changing JSON string

2011-06-10 Thread Mark Rathwell
I don't think the issue you are having is with slurp. If you could post more of the code that is causing you problems, it would be easier to debug. Entering the following at the repl seems to work fine for me (you can just do (slurp http://tycho.usno.navy.mil/cgi-bin/timer.pl;) and notice that

Re: Free Compojure Hosting? (or mostly free)

2011-06-10 Thread Asim Jalis
I tried this also and it works quite well. Do you have any pointers to information on how to access the datastore on Heroku through Clojure? The documentation seemed sketchy on their non-Ruby offerings. Thanks. Asim On Tue, Jun 7, 2011 at 9:37 PM, Sean Corfield seancorfi...@gmail.com wrote: I

Ideas from Fortress

2011-06-10 Thread Brent Millare
Has there been discussion about unicode support for symbols in clojure? There's a few ways to approach this and I'm thinking about fortress accomplishes this [1]. The language can be displayed as ascii, unicode, or even pictures. I think support for these things might be good for things like

Re: Free Compojure Hosting? (or mostly free)

2011-06-10 Thread David Powell
On Fri, Jun 10, 2011 at 3:26 PM, Asim Jalis asimja...@gmail.com wrote: I tried this also and it works quite well. Do you have any pointers to information on how to access the datastore on Heroku through Clojure? The documentation seemed sketchy on their non-Ruby offerings. I've not tried it,

ClojureBox on Window 7: classpath in .emacs file not working

2011-06-10 Thread rsgoheen
This is absolutely killing me. I'm starting to use ClojureBox to further my knowledge of Clojure, and I can't get it to pick up the individual *.clj files I'm working with or the example code from Halloway's book. There's lots of good information on line telling me how to set up my .emacs file,

transients are not designed to be bashed in-place

2011-06-10 Thread alsor
... but what if this is exactly what I need? I'm working with Lucene and I have my custom Collector. This collector accept fn as a constructor argument and then for each matched document it gathers needed information from the fields of document, builds some useful clojure object and passes it

Re: transients are not designed to be bashed in-place

2011-06-10 Thread David Nolen
On Fri, Jun 10, 2011 at 11:16 AM, alsor alsor@gmail.com wrote: ... but what if this is exactly what I need? I'm working with Lucene and I have my custom Collector. This collector accept fn as a constructor argument and then for each matched document it gathers needed information from the

Re: Singly linked lists as an immutable data structure

2011-06-10 Thread Ken Wesson
Of course, lazy Clojure functions like concat end up basically doing this: (def q (concat '(1 2 3) '(4))) q | | V [lazy-concat] | | V V '(1 2 3) '(4) The result of a lot of concats ends up therefore being a tree structure under the hood. It can be

Re: transients are not designed to be bashed in-place

2011-06-10 Thread Ken Wesson
This might break even without future Clojure changes. It's a really bad idea. If you really must go with a mutable accumulator, you should use something like (let [v (atom []) f (fn [obj] (swap! v conj obj))] (.search searcher (MatchAllDocsQuery.)

Svar: transients are not designed to be bashed in-place

2011-06-10 Thread Stuart Sierra
Yes, ignoring the return value of transient-modifier functions is not guaranteed to work. Even in current Clojure, it won't always work. Transient data structures are usually passed around as a parameter to a loop/recur or recursive function call. -Stuart Sierra clojure.com -- You received

Svar: Ideas from Fortress

2011-06-10 Thread Stuart Sierra
Symbols already permit Unicode characters. The Clojure reader assumes UTF-8. This may or may not render in G. Groups, though: user= (def π (Math/PI)) #'user/π user= π 3.141592653589793 Of course, there's no actual layout, but you could write code that reads a mathematical expression in

Re: Using slurp to read changing JSON string

2011-06-10 Thread Thomas
Hi Mark et al, I just tried your code and it does indeed work fine. It updates the time as expected. Not sure why my code isn't working as expect... a more investigating to do. Thomas ps. the web string won't start updating again until Monday morning. On Jun 10, 3:30 pm, Mark Rathwell

Re: hammock driven development...

2011-06-10 Thread Raoul Duke
The knack lies in learning how to throw yourself at the ground and miss. -- 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

Re: Radically simplified Emacs and SLIME setup

2011-06-10 Thread Phil Hagelberg
On Jun 9, 6:14 pm, Mark Engelberg mark.engelb...@gmail.com wrote: On Thu, Jun 9, 2011 at 8:20 AM, Jeff Dik s45...@gmail.com wrote: I had to change a s-exp on line 848 in clojure-mode.el from    (expand-file-name clojure-root) to    (replace-regexp-in-string / (expand-file-name

Re: hammock driven development...

2011-06-10 Thread Luc Prefontaine
A hot bath is for me is the best moment to do this. I let my mind loose not thinking about anything specific. My wife think I am in this state continuously but that's another discussion :). Of course, using a hammock outside here in January/February by -25 Celsius would literally freeze my mind