2010/1/21 Chris Kent :
> partition creates a sequence of sequences of adjacent values
>
> user=> (partition 2 (range 1 7))
> ((1 2) (3 4) (5 6))
>
> and you can apply reduce to each of the sequences using map
>
> user=> (map #(reduce + %) (partition 2 (range 1 7)))
> (3 7 11)
>
> or
>
> user=> (map
How do people deal with this? How can one simultaneously use two
libraries which have hardwired dependencies on two different Clojure
versions, each of which might be mutually incompatible?
What's the community protocol around locally installing Clojure 1.2,
and adding that as a dependency for a
Richard Newman writes:
> Adjusting the lein script to use my local Clojure install gave me a
> great error:
>
> Caused by: java.lang.NoSuchMethodError: clojure.lang.RestFn.(I)V
>
> How do people deal with this? How can one simultaneously use two
> libraries which have hardwired dependencies on tw
Oops you're right :) And better written as well :D
On Fri, Jan 22, 2010 at 1:26 AM, Richard Newman wrote:
> I agree, one possible improvement would be short circuiting on the first
>> false pred.
>>
>
> every? does short-circuit.
>
> user=> (every? #(% 5)
> (list
>
I agree, one possible improvement would be short circuiting on the
first false pred.
every? does short-circuit.
user=> (every? #(% 5)
(list
(fn [a] (println "First a: " a) false)
(fn [a] (println "Second a: " a) true)))
First a: 5
false
--
Yo
We're not all jumping on Leiningen, some of us are sticking with
maven, using the maven-clojure-compiler plugin, and also the
experimental Maven Polyglot Clojure build support:
It's not the "Leiningen" that's important, it's the "jumping": away
from Ant, not Maven. Every library I use had an A
I agree, one possible improvement would be short circuiting on the first
false pred.
(defn combine-preds [pred & others]
(fn [v]
(loop [result true pred pred others others]
(if (not result)
result
(if (nil? pred)
result
(recur (pred v) (first others)
We're not all jumping on Leiningen, some of us are sticking with
maven, using the maven-clojure-compiler plugin, and also the
experimental Maven Polyglot Clojure build support:
http://polyglot.sonatype.org/clojure.html
(disclojure - both of these are my projects so I'm somewhat biased)
--
Pu
I find that injecting print statements is painful if you're not using
something like paredit (Emacs). With paredit it's quite simple.
On Thu, Jan 21, 2010 at 8:27 PM, ajay gopalakrishnan wrote:
> Is this the preferred way of debugging in Clojure?
>
>
> On Thu, Jan 21, 2010 at 5:25 PM, Richard New
What is the clojure idiom for running multiple (in this case IO bound)
functions simultaneously? My use case is the parallel activities are
coordinated, basically running in lockstep. I've been using (.start
(Thread. myfn)). It works, but I'm wondering if there's a better way.
The data shared b
On Jan 21, 8:37 pm, Sean Devlin wrote:
> Clojure stresses immutability, and dependencies should be no
> different. I'd say it's bad form to force a dependency on an
> unreleased version of Clojure, because it's a moving target. Granted,
BTW, Clojure also stresses *controlled mutability*. I'd
Sometimes you don't want assoc-in to create a hash-map. Sometimes you
wish it could create a sorted map.
Just finished working on something with Alexy Khrabrov & Chouser on
IRC, and the three of us are wondering if the result might be
generally useful.
(defn assoc-in-with
"supply a default-map
Logging side-effects usually occur within a do block, or the
equivalent, e.g., when, catch. For production code, I'd suggest a
logging library instead of filling your code with printlns. Contrib
has a logging lib that delegates to common java logging libraries, but
allows for writing them in a mo
I don't know about *the* preferred way, but it's my preferred way.
It's a no-brainer to add print statements. I believe there is at
least one logging library available too.
On Jan 21, 7:27 pm, ajay gopalakrishnan wrote:
> Is this the preferred way of debugging in Clojure?
>
> On Thu, Jan 21, 201
> What's the community protocol around locally installing Clojure 1.2,
> and adding that as a dependency for a published library?
I'll take a shot at this question.
Clojure stresses immutability, and dependencies should be no
different. I'd say it's bad form to force a dependency on an
unrelea
Is this the preferred way of debugging in Clojure?
On Thu, Jan 21, 2010 at 5:25 PM, Richard Newman wrote:
> I usually debug by adding println statements. How can I achieve the same
>> effect in Clojure. I don't think I can introduce println at arbitrary places
>> to figure out at which step is t
I usually debug by adding println statements. How can I achieve the
same effect in Clojure. I don't think I can introduce println at
arbitrary places to figure out at which step is the algorithm failing.
Sure you can. You might need to add a (do ) block if you're wanting to
add them in an (
Hi folks,
Apparently everyone is jumping on the Leiningen bandwagon and deleting
their build.xml files. I guess that means I'm moving, too.
Now, I like to keep track of Clojure master. Right now, Clojure
reports "Clojure 1.2.0-master-SNAPSHOT".
(I don't see that in Maven Central or in Clo
Hi,
I usually debug by adding println statements. How can I achieve the same
effect in Clojure. I don't think I can introduce println at arbitrary places
to figure out at which step is the algorithm failing.
Thanks,
Ajay
--
You received this message because you are subscribed to the Google
Grou
Hello,
Is there a way to do a loss free print/read loop in clojure?! I know
that data structures like maps, vectors, .. maybe printed and read
without the loss of information but it does not work for functions.
Does clojure provide a the possibility to retrieve the data structure
that represents
You have your arguments out of order, try:
(= (.replaceAll "a" "\"" "\\\"")
(.replaceAll "\\a" "\"" "\\\""))
On Thu, Jan 21, 2010 at 2:40 PM, CuppoJava wrote:
> Hi,
> I'm trying to write a simple function to replace every " inside the
> string with \", but am having an extremely difficult ti
Your second "\\a" should probably be "\"a".
On Jan 21, 5:40 pm, CuppoJava wrote:
> Hi,
> I'm trying to write a simple function to replace every " inside the
> string with \", but am having an extremely difficult time.
>
> Can someone enlighten me as to why the following is returning true?
>
> (=
Hi,
I'm trying to write a simple function to replace every " inside the
string with \", but am having an extremely difficult time.
Can someone enlighten me as to why the following is returning true?
(= (.replaceAll "\"" "\\\"" "a")
(.replaceAll "\"" "\\\"" "\\a"))
Thanks a lot
-Patrick
--
On Jan 21, 2010, at 19:08 , CuppoJava wrote:
> The last point that interested me was: I heard someone mention that
> applications written using the Apple Java-Cocoa bridge was also
> noticeably less responsive than native applications in Objective-C,
> that person said it's because of java's GC th
Not as a macro I hope. You lose apply.
On Jan 21, 3:49 pm, Richard Newman wrote:
> > I think it's easier to think about combining predicates separately
> > from your file-filtering code. I'd use a higher-order function like
> > the following
>
> > (defn combine-preds
> > [& preds]
> > (fn
I think it's easier to think about combining predicates separately
from your file-filtering code. I'd use a higher-order function like
the following
(defn combine-preds
[& preds]
(fn [& args] (every? #(apply % args) preds)))
I've noticed that most uses of this kind of thing are for fixed
I agree with Perry. I've found I have to write two versions of
combine-preds often
(defn every-pred?
"Mimics AND"
[& preds]
(fn [& args] (every? #(apply % args) preds)))
(defn any-pred?
"Mimics OR"
[& preds]
(fn [& args] (some #(apply % args) preds)))
They're very handy,
I think it's easier to think about combining predicates separately
from your file-filtering code. I'd use a higher-order function like
the following
(defn combine-preds
[& preds]
(fn [& args] (every? #(apply % args) preds)))
then filter files like
(filter (combine-preds pred1 pred2)
> Often you will also get better behavior by using appropriate -Xms/-Xmx
> options. The above are just examples of course and not "the" way to do
> it or anything.
i would like a JVM that has a "hot spot jit" for GC tweaking.
--
You received this message because you are subscribed to the Google
G
Brilliant. Thanks Dan, that did the trick.
On Jan 21, 8:01 pm, Dan Schmidt wrote:
> I don't know how efficient it is (or how idiomatic it really is), but
> this should work:
>
> (defn find-files
> "Find files in directory that match predicates pred & others"
> [in-dir pred & others]
> (reduce
I don't know how efficient it is (or how idiomatic it really is), but
this should work:
(defn find-files
"Find files in directory that match predicates pred & others"
[in-dir pred & others]
(reduce (fn [xs f] (filter f xs)) (file-seq in-dir) (cons pred others)))
Dan
On Thu, Jan 21, 2010 at 2:
I'm not quite sure what you're getting at. Maybe split-with will do
what you want?
http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/split-with
On Jan 21, 2:47 pm, nwalex wrote:
> I'm very new to Clojure, and to functional programming in general. Can
> anyone tell me the i
> It seems the consensus is that the slow responsiveness of Java apps is
> mostly due to an issue with Swing and how it is used rather than with
> garbage collection. That sounds very encouraging.
Determining whether the GC is responsible is pretty easy. Just runt
with -verbose:gc (or -XX:+PrintGC
I'm very new to Clojure, and to functional programming in general. Can
anyone tell me the idiomatic way to implement this function?
(defn find-files
"Find files in directory that match predicates pred & others"
[in-dir pred & others]
(filter pred (file-seq in-dir)))
What is the best way to
Thanks for the responses.
It seems the consensus is that the slow responsiveness of Java apps is
mostly due to an issue with Swing and how it is used rather than with
garbage collection. That sounds very encouraging.
The last point that interested me was: I heard someone mention that
applications
Just a quick note about getting setup with Leiningen. The
documentation you posted says to use [autodoc "0.7.0-SNAPSHOT"] in the
dev dependencies, but that is not a valid package on clojars. Using
[autodoc "0.7.0"] instead works fine though. No downloading of jars
necessary. Just add that, run
Hi,
After reading Stuart Sierra's post titled "Agents of Swing" [1] I
couldn't wait to try and port it to Jwt [2].
I finally had the time and documented it in a blog post at
http://www.nsa.be/index.php/eng/Blog/From-Swing-to-Jwt
I thought this could be of interest to some people here, expecially
Seconded. I found this very confusing when I first started with Clojure.
2010/1/21 Alex Stoddard
> Hello,
>
> As detailed in Bradford Cross' blog, (http://
> measuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging-
> and-how.html) the rebinding of *out* done in the swank/slime repl
Thanks!
On Jan 21, 7:07 am, Meikel Brandmeyer wrote:
> Hi,
>
> On Jan 20, 8:03 pm, Scott wrote:
>
> > (reduce-n + (range 7) 2)
> > => (3 7 11)
>
> user=> (map #(reduce + %1) (partition 2 (range 1 7)))
> (3 7 11)
>
> Sincerely
> Meikel
--
You received this message because you are subscribed to
There is a plugin for leiningen that creates war files for use with
servlet containers:
http://github.com/alienscience/leiningen-war/
http://clojars.org/uk.org.alienscience/leiningen-war
To use it include the following dev-dependency in project.clj
:dev-dependencies [[uk.org.alienscience/leining
Hello,
As detailed in Bradford Cross' blog, (http://
measuringmeasures.blogspot.com/2010/01/agony-of-clojurehadoop-logging-
and-how.html) the rebinding of *out* done in the swank/slime repl can
be very confusing to folk who don't already know slime. This is
because so many java libraries output to
Promises (and dataflow programming in general) are really useful with
interacting with physical devices, especially robots. Suppose you
have a 200 ton press, with a safety sensor. You have the following
code:
(def is-it-safe? (promise))
(defn activate-press []
(if @is-it-safe?
(go!)))
(d
On Jan 21, 3:20 am, Joonas Pulakka wrote:
> In general, accusing garbage collection of being culprit for sluggish
> GUI performance is plain wrong. Swing GUIs can be quite snappy when
> done right - but surely there are lots of not-so-right done apps out
> there.
>From my limited experience with
Tom,
Thanks for providing this great tool. I was able to install it last
night, it just plain works.
Keep hacking!
Sean
On Jan 20, 12:51 pm, Tom Faulhaber wrote:
> Now your project can have the same documentation as Clojure, clojure-
> contrib, and Incanter!
>
> The standalone autodoc tool is n
Clojure has a Ratio type; presumably there should be an easy way to
find the numerator and denominator of a Ratio object.
I didn't have much luck on clojure.org or with find-doc, but
(show 1/2)
taught me that there are numerator and denominator methods on Ratio's
underlying Java implementati
> I think you misread the source of fnmap. Of course it creates a new
> map in the beginning just as hash-map does. Then assoc/dissoc/etc.
> just delegates to the underlying map with the appropriate fiddling
> with the setter/getter.
>
> If you already have a map you can do something like:
>
> (req
I don't think zipper would help in this case
On Jan 21, 12:40 am, brianh wrote:
> Any chance you could rethink your approach & use a zipper?
>
> On Jan 20, 9:32 am, Gabi wrote:
>
> > I posted a question on SO about it. Interesting
> > discussion:http://stackoverflow.com/questions/2102606/algori
Hi,
On Jan 21, 11:01 am, "C. Florian Ebeling"
wrote:
> This is actually a very cool approach and it fits my ideas quite well.
> The only problem I have with it is that it constructs a whole new map
> from keyvals. Maybe it is possible do something similar which just wraps
> over an existing map.
Hi,
On Jan 20, 8:03 pm, Scott wrote:
> (reduce-n + (range 7) 2)
> => (3 7 11)
user=> (map #(reduce + %1) (partition 2 (range 1 7)))
(3 7 11)
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo
Hi,
On Jan 20, 11:10 pm, Bryce wrote:
> What am I missing?
Try ` instead of '. eval evaluates the expression with a different ns.
Since y is not properly quoted it is not found. ` will resolve y to
its qualified name and everything will work out.
Standard Disclaimer: this is only one subtle go
Hi,
> (defn y [a b] (+ a b))
> (def x '(y 1 2))
>
> (defn -main []
> (println (eval x)))
>
> which yields
>
> "Unable to resolve symbol: y in this context (NO_SOURCE_FILE:7)"
> etc.
> What am I missing?
The problem is namespace inside the function used by gen-class (and it
this case your -main
partition creates a sequence of sequences of adjacent values
user=> (partition 2 (range 1 7))
((1 2) (3 4) (5 6))
and you can apply reduce to each of the sequences using map
user=> (map #(reduce + %) (partition 2 (range 1 7)))
(3 7 11)
or
user=> (map (partial reduce + ) (partition 2 (range 1 7
On 20.01.2010, at 20:03, Scott wrote:
looking for something very similar to reduce, but sequentially operate
on adjacent values
for example
if
(defn reduce-n [f col n])
(reduce-n + (range 7) 2)
=> (3 7 11)
ie
1+2, 3+4, 5+6
ideas?
That's (range 1 7) instead of (range 7), right? In that ca
The attr-map adds key-value pairs to the metadata for the function
symbol. The doc for 'defn' makes this clearer.
On Jan 20, 8:02 am, Jacek Generowicz
wrote:
> In Clojure 1.1.0, the documentation states:
>
> clojure.core/defmulti
> ([name docstring? attr-map? dispatch-fn & options])
> Macro
> C
On Jan 20, 1:02 pm, Jacek Generowicz
wrote:
> clojure.core/defmulti
> ([name docstring? attr-map? dispatch-fn & options])
> What is the purpose of the attribute map [...] ?
Answering my own question: It's not specific to multimethods. It's the
metadata, and most def- forms have such an optional
I'm a clojure newbie, but bear with me; I'm trying to save an
expression that contains a function I've defined earlier, and then
selectively evaluate it later. (The idea is that I will swap out the
function later in the code). Something like
(defn y [a b] (+ a b))
(def x '(y 1 2))
(defn -main [
Hi,
Am 20.01.2010 um 14:02 schrieb Jacek Generowicz:
> In Clojure 1.1.0, the documentation states:
>
> clojure.core/defmulti
> ([name docstring? attr-map? dispatch-fn & options])
> Macro
> Creates a new multimethod with the associated dispatch function.
> The docstring and attribute-map are op
looking for something very similar to reduce, but sequentially operate
on adjacent values
for example
if
(defn reduce-n [f col n])
(reduce-n + (range 7) 2)
=> (3 7 11)
ie
1+2, 3+4, 5+6
ideas?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To pos
On Wed, Jan 20, 2010 at 12:51 PM, Tom Faulhaber wrote:
> Now your project can have the same documentation as Clojure, clojure-
> contrib, and Incanter!
>
> The standalone autodoc tool is now available. It can be run from the
> command line and it integrates with Leiningen and ant. (Maven still to
In a nutshell, those are the building blocks for the "dataflow
programming paradigm".
It's an easy way to make a computation done in thread A (and using a
pre-declared promise) block until thread B has delivered the promise
(given it its value).
The book CTM covers dataflow programming :
http://w
Hello,
I am trying to understand the use-cases of the new promise/deliver
feature in Clojure. I have tried using them, and they seem to be
pretty straight-forward to use, but unfortunately I haven't been able
to understand its use-cases.
It would be great if someone pointed out some example usage
> There's a library in clojure.contrib which allows to create your own
> getters / setters for maps :
>
> http://richhickey.github.com/clojure-contrib/fnmap-api.html
This is actually a very cool approach and it fits my ideas quite well.
The only problem I have with it is that it constructs a whole
In general, accusing garbage collection of being culprit for sluggish
GUI performance is plain wrong. Swing GUIs can be quite snappy when
done right - but surely there are lots of not-so-right done apps out
there.
Also, the amount of GC required depends a lot on what you're doing,
and how. Typical
63 matches
Mail list logo