>> I wonder if there is a more idiomatic way to compare two lazy
>> sequences... lazily?
You can just use =.
(= seq1 seq2)
It works lazily.
user> (= (iterate inc 0) (map #(do (println %) %) [0 1 2 -3 4 5 6]) )
0
1
2
-3
false
How sweet!
2009/5/28 Daniel Lyons :
>
>
> On May 27, 2009, at 11:5
On Thu, May 28, 2009 at 7:58 AM, Daniel Lyons wrote:
>
>
> On May 27, 2009, at 11:51 PM, Timothy Pratley wrote:
>> I wonder if there is a more idiomatic way to compare two lazy
>> sequences... lazily?
>
> I came up with (some (complement zero?) (map compare list-1 list-2))
> in my response which
On May 26, 2009, at 10:56 PM, kyle smith wrote:
> Thanks for the feedback Daniel, I've incorporated your ideas and re-
> uploaded. I'm not sure where you're seeing mutable data structures.
I'm hallucinating, that's where. :)
> Anyhow, I now only call eval once each time scorer is called, whic
On May 27, 2009, at 11:51 PM, Timothy Pratley wrote:
> I wonder if there is a more idiomatic way to compare two lazy
> sequences... lazily?
I came up with (some (complement zero?) (map compare list-1 list-2))
in my response which missed yours by seconds. :) I'm not sure it's
great but it doe
On May 27, 2009, at 7:52 PM, Korny Sietsma wrote:
> How would I do this in a functional way? My first effort would be
> something like
>(defn hash [filename] (memoize (... hash function ...)))
> but I have a couple of problems with this:
> - it doesn't seem to store the hash value with the
Yes that is a very elegant solution.
For convenience you might want another function:
(defn fast-compare
"Given two filenames returns true if the files are identical"
[fn1 fn2]
(let [i1 (get-info fn1), i2 (get-info fn2)]
(and (= (first i1) (first i2))
(= (second i1) (second i2))
Hash calculation runs only when necessary, because
Clojure's map function is lazy now.
more sample code:
(nth (get-info "a.txt") 0)
(nth (get-info "b.txt") 0)
(nth (get-info "b.txt") 1)
result:
size a.txt
size b.txt
quickhash b.txt
Output result shows it.
When
(nth (get-info "a.txt") 0)
is ev
On 27/05/2009, Baishampayan Ghose wrote:
..
> In the SLIME REPL, press , (comma) and then type 'quit' and press Enter.
>
> That'd close your REPL gracefully after which you can exit Emacs by
> pressing C-x C-c.
>
> Regards,
> BG
>
> --
Exactly what I wanted. Many thanks!
Regards,
Muhammad
> Ba
Sounds like a job for lazy-map to me!
http://kotka.de/projects/clojure/lazy-map.html
On May 28, 11:52 am, Korny Sietsma wrote:
> Hi all,
>
> I have some ruby code that I'm thinking of porting to clojure, but I'm
> not sure how to translate this idiom to a functional world:
> I have objects that
Trouble here is, I only want to call the hash functions as needed.
This is doing file differencing, and if I only have a single file of
(say) 200 megabytes, I never need to calculate it's hash, as I'll
never actually compare it to another file of exactly the same size.
- Korny
On Thu, May 28, 20
Hello.
I am new to clojure, but try it.
code:
(defn get-size [filename]
(println 'size filename)
(count filename))
(defn get-quickhash [filename]
(println 'quickhash filename)
(hash (take 3 filename)))
(defn get-hash [filename]
(println 'hash filenam
Hi all,
I have some ruby code that I'm thinking of porting to clojure, but I'm
not sure how to translate this idiom to a functional world:
I have objects that are externally immutable, but have internal
mutable state they use for optimisation, specifically in this case to
defer un-needed calculat
Hello,
Here's what I've done in times past:
(ns process-xml-in-a-file
(:require [clojure.zip :as zip])
(:require [clojure.contrib.zip-filter.xml :as zfx])
(:require [clojure.xml :as xml]))
; creating list of all checkable instances
(def dev2-cfg-xml
(-> "c:/dl/tibsup/Prod_Stg_auto_shutd
Hi Drew,
I've been trying to recreate your issue
(defn forever[x] (while true (Thread/sleep 100) (print \-) (flush)))
(let [a (agent 0)] (send (agent 0) forever))
(println (Thread/activeCount) "threads active")
(shutdown-agents)
(println "I'm here")
;(System/exit 0)
Notably shutdown-agents i
Hi,
I'm trying to write some macro-defining macros, and the recursive
backquotes are making my brain spin circles. Is there a macro writing
helper so that I can expand my macros level by level and see the
intermediate result?
I'm using macroexpand-1 right now, but it's not terribly useful as
back
wow. the fact that people use java+somehatefullibs+xml and apparently
think that is something "good", completely drives me insane. i mean,
it isn't just additional bloat, it is more like
ackermann-function-scale bloat. gargh! has anybody done something
like:
1) convert the bloody XML to Clojure l
On May 26, 10:47 pm, markgunnels wrote:
> Hopefully this doesn't get me booed off the message board but is there
> a Clojure equivalent to Ruby's ERB? I'm try to use Clojure to perform
> code generation
I've had success with StringTemplate. Very functional design, easy to
call from Clojure. An
I think you could do a hack using macros and eval at runtime in order
to expand them into your code, but I think one of the fellas in the
chat room said to be wary if that's the only approach I can see to a
problem, because it's easy to screw up, and not entirely good
practice.
Btw, does clojure
Dear Clojurians,
this is the next iteration of my Ivy experiments
to provide a modular build of contrib. With the
support of Kresimir Sojat I restructured the build.
Previously the different contrib modules were
provided as configurations. This is now changed
in that every contrib module is also
billh04 wrote:
> I think you are responsible for ending the currently running
> agents. The usual method is to set up some field which the agents
> monitor looking for some value indicating the application is
> ending.
By "ending currently running agents" do you mean the action run on
the agent
I wrote a patch for issue #13 a few weeks back, but it was right around
the 1.0 push, so I didn't want to destabilize things. Now seems like a
good time to discuss it:
http://code.google.com/p/clojure/issues/detail?id=13
This uses the reader to ensure that symbols and keywords have names that
Thanks. This looks awesome.
On May 27, 10:28 am, ritchie turner wrote:
> Hi there
>
> Find attached some code that uses apache velocity for command line based
> processing, i.e. it's not setup for servlets; i use this as an offline
> pre processor for web sites.
>
> It does hierarchical templati
+1 for better info on :use/:require. I find I tend to go digging into
the clojure-contrib source for decent examples just because I'm not
sure where else to look.
On May 27, 11:03 am, tsuraan wrote:
> > Here's the correct syntax:
>
> > (ns namespace
> > (:use [other-namespace :rename {existin
Makes sense, thanks!
On Wed, May 27, 2009 at 11:30 AM, Konrad Hinsen
wrote:
>
> On May 27, 2009, at 17:11, Boris Mizhen - 迷阵 wrote:
>
>> It seems to me that the first would be immune to redefining what
>> closure/core.let means at the point where f is invoked, while the
>> second one would not b
On May 27, 2009, at 1:03, aperotte wrote:
> I think I understand your point now. You would like the indexing to
> match the implicit dimension order of the nested structure.
Right.
> I was also concerned about storage order because I wanted to at some
> point integrate this datastructure with
On May 27, 2009, at 17:11, Boris Mizhen - 迷阵 wrote:
> It seems to me that the first would be immune to redefining what
> closure/core.let means at the point where f is invoked, while the
> second one would not be.
No. Both definitions create a closure inside which x has the fixed
value 2. When
It seems to me that the first would be immune to redefining what
closure/core.let means at the point where f is invoked, while the
second one would not be.
I was unable to actually redefine closure/core.let - probably because
it is a macro. But some function was used in place of let, than it
coul
On May 27, 7:59 am, Frantisek Sodomka wrote:
> Thanks for the help and your feedback, Steve!
>
> Clojure needs some unit tests and I like writing them, so it is a win-
> win situation :-)
>
Let me add my thanks as well - this is a great (and otherwise
thankless :) contribution.
I also wanted
Hi there
Find attached some code that uses apache velocity for command line based
processing, i.e. it's not setup for servlets; i use this as an offline
pre processor for web sites.
It does hierarchical templating of files in a source directory and
copies to a target directory. The templating ma
> Here's the correct syntax:
>
> (ns namespace
>(:use [other-namespace :rename {existing newname}]))
aha, brackets. Is there a plan to flesh out the API page to have more
examples of things like that? As it stands, I think the API page is
probably great for somebody who needs a reminder, bu
Thanks for the help and your feedback, Steve!
Clojure needs some unit tests and I like writing them, so it is a win-
win situation :-)
Yes, this is our first test in clojure-contrib.test-clojure.vars. I
checked it in together with other changes as revision 846.
Frantisek
On May 26, 9:27 pm, "
No, I was just worried that using def/defn not at the top level, but
inside a let, might have unforeseen consequences.
On Wed, May 27, 2009 at 3:48 AM, Rich Hickey wrote:
> No, are you experiencing one?
>
--~--~-~--~~~---~--~~
You received this message because yo
On May 27, 4:47 am, markgunnels wrote:
> Hopefully this doesn't get me booed off the message board but is there
> a Clojure equivalent to Ruby's ERB?
I don't think there is a Clojure equivalent (i.e. for general purpose
text generation), but given Clojure's great Java integration you could
easil
On May 27, 4:12 am, Mark Engelberg wrote:
> Is there any practical difference between:
>
> (let [x 2]
> (defn f [] x))
>
> and
>
> (def f (let [x 2] (fn [] x)))?
No, are you experiencing one?
Rich
--~--~-~--~~~---~--~~
You received this message because you ar
> I have just started learning Clojure, and I found Clojure Box (http://
> clojure.bighugh.com/) to be an easy installation for that.
> Unfortunately, I am not sure about the right way to exit from the
> prompt.
> After starting Clojure Box and using the prompt (possibly including
> loading and sa
Hi everyone,
I have just started learning Clojure, and I found Clojure Box (http://
clojure.bighugh.com/) to be an easy installation for that.
Unfortunately, I am not sure about the right way to exit from the
prompt.
After starting Clojure Box and using the prompt (possibly including
loading and
Hopefully this doesn't get me booed off the message board but is there
a Clojure equivalent to Ruby's ERB? I'm try to use Clojure to perform
code generation and, while it makes for an excellent language to write
a parser in, I can't quite figure out the best way to actually
template out the code.
For those without a Google Alert set up for Clojure:
"In this interview taped at QCon London 2009 Rich Hickey talks about
Clojure, shortly before the 1.0 release."
http://www.infoq.com/news/2009/05/hickey-clojure
42 minute video:
http://www.infoq.com/interviews/hickey-clojure
Is there any practical difference between:
(let [x 2]
(defn f [] x))
and
(def f (let [x 2] (fn [] x)))?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to cloju
39 matches
Mail list logo