Hi,
On Aug 3, 10:10 pm, John Harrop wrote:
> (defn and-ns
> "A non-short-circuiting \"and\" usable in reduce etc."
> ([] true)
> ([a] a)
> ([a b] (and a b))
> ([a b & more] (reduce and-ns (and a b) more)))
Don't think to complicated.
(reduce #(and %1 %2) coll)
This should d
Hi,
On Aug 3, 11:43 pm, samppi wrote:
> (def my-map {:a 2})
> (defn process-a-map [arg] ...)
> ; Turns maps into corresponding vectors.
> ; (process-a-map my-map) returns ['*foo* :blah].
>
> (my-macro a-map ; Last statement
> (do-something))
The answer which should leave the
James Reeves writes:
> I've been sketching out a design for a package manager for Clojure,
> similar to Rubygems. To the best of my knowledge, there's no real
> equivalent to this in Java-land.
>
> I'm looking for suggestions, criticisms, or for someone to tell me
> that Java already has a packa
On Aug 3, 6:19 pm, ataggart wrote:
> Here's the well-hidden, auto-generated docs for clojure-contrib:
>
> http://richhickey.github.com/clojure-contrib/
>
Thx. That's what i've been looking for.
--~--~-~--~~~---~--~~
You received this message because you are sub
Here's the well-hidden, auto-generated docs for clojure-contrib:
http://richhickey.github.com/clojure-contrib/
On Aug 3, 5:41 pm, James Sofra wrote:
> I think he may mean
> thishttp://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib
> Is it still being updated?
> It says "Updated Jun
I think he may mean this
http://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib
Is it still being updated?
It says "Updated Jun 15, 2009 by tomfaulhaber"
Cheers,
James
On Aug 4, 10:24 am, Mike Hinchey wrote:
> Do you mean this?http://clojure.org/libraries
--~--~-~--~~---
On Mon, Aug 3, 2009 at 8:01 PM, CuppoJava wrote:
>
> You can use eval to retrieve the value of a-map when the macro is
> expanded.
>
> (let [value (eval a-map)]
> `(binding ~(vec (process-a-map value)) ~...@forms))
>
> I've programmed some substantial programs now in Clojure though, and
> I've ne
I like it. I can see significant use of these to help speed up some
of the benchmark programs I've been hacking on:
git://github.com/jafingerhut/clojure-benchmarks.git
and more importantly, that means they can be good in optimizing useful
code, too :-)
I was pondering this question "If a pure
On Mon, Aug 3, 2009 at 7:27 PM, CuppoJava wrote:
>
> Hi Rich,
> This is a very useful addition thanks. I personally find the O(1)
> transformation to and back most useful.
>
> I have a question about capturing the return values of conj! and
> assoc!.
>
> in this code:
> (let [v (transient [])
>
On Mon, Aug 3, 2009 at 5:43 PM, samppi wrote:
> I'm getting stuck because a-map always gets passed into my-macro
> as a symbol.
>
> (defmacro my-macro [a-map & forms] ; Naive implementation
>`(binding ~(vec (process-a-map a-map)) ~...@forms))
Try
(defmacro my-macro [a-map & forms] ; Naive
On Mon, Aug 3, 2009 at 5:39 PM, Rich Hickey wrote:
> In short, the O(1) overhead is less than the cost of even a single
> edit. So, e.g. into/vec/vector now use transients unconditionally if
> possible.
Excellent. I'm glad to hear that the core functions will use
transients so I don't have to ma
On Aug 3, 8:06 pm, Mark Engelberg wrote:
> So if you want to make 10 changes to a vector, would it be worthwhile
> to turn it into a transient, make the 10 changes, and then turn it
> back to persistent? If no, then 100 changes? 1000?
>
> In other words, how much overhead is there in the tran
On Aug 3, 7:27 pm, CuppoJava wrote:
> Hi Rich,
> This is a very useful addition thanks. I personally find the O(1)
> transformation to and back most useful.
>
> I have a question about capturing the return values of conj! and
> assoc!.
>
> in this code:
> (let [v (transient [])
> v2 (con
Do you mean this? http://clojure.org/libraries
--~--~-~--~~~---~--~~
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 moderat
There was this awesome browsable list of clojure libraries with short
description of each, list of functions and even links to source.
Now it all replaced with link to github.
Please bring the user friendly and easily browsable documentation
back!
--~--~-~--~~~---~--
So if you want to make 10 changes to a vector, would it be worthwhile
to turn it into a transient, make the 10 changes, and then turn it
back to persistent? If no, then 100 changes? 1000?
In other words, how much overhead is there in the transformation back
and forth, and therefore, about how m
You can use eval to retrieve the value of a-map when the macro is
expanded.
(let [value (eval a-map)]
`(binding ~(vec (process-a-map value)) ~...@forms))
I've programmed some substantial programs now in Clojure though, and
I've never had to use this. Perhaps there is another way to achieve
wha
Hi Rich,
This is a very useful addition thanks. I personally find the O(1)
transformation to and back most useful.
I have a question about capturing the return values of conj! and
assoc!.
in this code:
(let [v (transient [])
v2 (conj! v 0)])
v2 is the captured return value from conj!, wh
I've been doing some work on Transient Data Structures. You can read
about them here:
http://clojure.org/transients
Feedback welcome,
Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to
On Aug 3, 5:52 pm, luke wrote:
> Interesting.
>
> So I take it that these are (or should be) entirely a speed
> optimization? i.e, most the time, you'd want to write your code using
> the normal persistent data structures, and only go back and implement
> this within specific functions if they'
Hi,
There is Apache Ivy (http://ant.apache.org/ivy/) with it's Packager
resolver that does exactly that (it has almost the same syntax as your
proposal).
For a repository using Apache Ivy + Package take a look at Ivy RoundUp
(http://code.google.com/p/ivyroundup/), good thing about there desing
i
Leotis buchanan writes:
> I located the process, using nstat, and then I killed it,This worked,
> however this also killed my slime connection, which is bad, how can I
> release the address without killing the slime connection ?
You are working on an earlier "step" of the mire codebase. In later
On Aug 3, 1:52 pm, luke wrote:
> So you could easily wrap an entirely functional code block
> in a transform-to-transient macro that translates the functions to
> their transient counterparts, and gain all the performance benefits?
I do not think it would be that easy. Transient mode cannot be u
On Mon, Aug 3, 2009 at 3:45 PM, Richard Newman wrote:
>
> > user=> (macroexpand-1 '(memfn add x y))
> > (clojure.core/fn [target__4193__auto__ x y] (. target__4193__auto__
> > (add x y)))
> >
> > That is, basically (fn [object x y] (.add object x y)).
>
> .add is macroexpanded into the more gener
Hi,
I modified the gen-struct macro a bit and got it to generate
simple, mutable and immutable structures. You can customize
only one aspect of those classes: their fields. Here's an example:
(gen-struct
:name my.test.struct
:mutable-fields [[float x]
[f
I'm trying to make a macro my-macro so that the last statement in:
(def my-map {:a 2})
(defn process-a-map [arg] ...)
; Turns maps into corresponding vectors.
; (process-a-map my-map) returns ['*foo* :blah].
(my-macro a-map ; Last statement
(do-something))
expands to:
(bind
Interesting.
So I take it that these are (or should be) entirely a speed
optimization? i.e, most the time, you'd want to write your code using
the normal persistent data structures, and only go back and implement
this within specific functions if they're a bottleneck? Sounds great.
And for a som
Nathan,
I located the process, using nstat, and then I killed it,This worked,
however this also killed my slime connection, which is bad, how can I
release the address without killing the slime connection ?
Leotis
On Sun, Aug 2, 2009 at 10:11 AM, Nathan Lefler wrote:
> Try either killing your
Hi folks,
I've been sketching out a design for a package manager for Clojure,
similar to Rubygems. To the best of my knowledge, there's no real
equivalent to this in Java-land.
I'm looking for suggestions, criticisms, or for someone to tell me
that Java already has a package manager that's bette
My two cents...
Given that we committed to Clojure to get our product out in production,
it's something
we took into account when we decided to go forward with it. After all we
did not want to change
the core of our product in 5 years... :)))
The way Clojure dev is handled presently is for us a p
Johann Kraus writes:
> Doing this with doubles:
> leads to:
> (time (maptest 8)) : 68044.060324 msecs
> (time (pmaptest 8)) : 35051.174503 msecs
> i.e. a speedup of ~2.
>
> However, the CPU usage indicated by "top" is ~690%. What does the CPU
> do?
My guess would be you're seeing the overhead
> user=> (macroexpand-1 '(memfn add x y))
> (clojure.core/fn [target__4193__auto__ x y] (. target__4193__auto__
> (add x y)))
>
> That is, basically (fn [object x y] (.add object x y)).
.add is macroexpanded into the more general dot form, as shown in the
memfn expansion.
user=> (read-string
On Mon, Aug 3, 2009 at 8:53 AM, Mike DeLaurentis wrote:
>
> I believe it stands for "member function". From the doc string:
>
> "Expands into code that creates a fn that expects to be passed an
> object and any args and calls the named instance method on the
> object passing the args. Use when
On Mon, Aug 3, 2009 at 4:16 AM, Adie wrote:
>
> Good Afternoon folks,
>
> I am a newbie to Clojure, coming from CL, with very little Java
> background.
> I am trying to use the 'javax.persistence' libraries, but i just cant
> seem to import it properly
>
> for e.g
> (import '(javax.persistence Pe
> However, the CPU usage indicated by "top" is ~690%. What does the CPU do?
100% per core. So with dual quad-core processors, it'd mean roughly 7
cores were being pegged.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Group
Hi,
Am 03.08.2009 um 16:56 schrieb Jonas Enlund:
In the following example :while and :when are interchangeable, which
is often the case when :while is used last in the list comprehension:
user=> (for [x (range 1 10) y (range 1 10) :while (< (+ x y) 5)] [x
y])
([1 1] [1 2] [1 3] [2 1] [2 2]
> When you put the :while at the `x` clause you get the expected empty
> seq.
>
> user=> (for [x (range 1 10) :while (= x 2) y (range 1 10)] [x y])
> ()
Interesting, I didn't know that.
Still, the behavior of :while feels strange. I guess I'll get used to it.
In the following example :while and
Hi,
On Aug 3, 10:16 am, Adie wrote:
> for e.g
> (import '(javax.persistence Persistence)
> gives a
> java.lang.ClassNotFoundException: javax.persistence.Persistence
> (NO_SOURCE_FILE:0) error
>
> How will i import javax.persistence properly?
You have to name the Classes or Interfaces in the `i
Ah, makes sense. Thanks.
On Mon, Aug 3, 2009 at 8:53 AM, Mike DeLaurentis wrote:
>
> I believe it stands for "member function". From the doc string:
>
> "Expands into code that creates a fn that expects to be passed an
> object and any args and calls the named instance method on the
> object p
On Mon, Aug 3, 2009 at 5:44 AM, Christophe Grand wrote:
> I think Mark's code exhibits a bug:
>
> (def my-ref (ref 1))
>
> (dosync
> (ref-set my-ref 5)
> (commute my-ref inc)) ; returns 6
>
> (println "my-ref =" @my-ref) ; prints 7
>
> since my-ref is ref-set, my-ref is in LockingTransaction/s
On Sun, Aug 2, 2009 at 3:28 PM, John Harrop wrote:
> On Sun, Aug 2, 2009 at 5:48 AM, James Sofra wrote:
>
>>
>> (defn get-tile [[x y] maze]
>> (if (tile-in-bounds? [x y] maze)
>>((maze y) x)))
>
>
> (defn get-tile [[x y] maze]
> (get (get maze y) x))
>
While you're at it, why not: (get-i
Hi,
On Aug 3, 8:47 am, Jonas wrote:
> I find the :while modifier non intuitive
>
> user=> (for [x (range 1 10) y (range 1 10) :while (= y 2)] [x y])
> ()
> user=> (for [x (range 1 10) y (range 1 10) :while (= x 2)] [x y])
> ([2 1] [2 2] [2 3] [2 4] [2 5] [2 6] [2 7] [2 8] [2 9])
>
> My (false) i
On Mon, Aug 3, 2009 at 2:47 AM, Jonas wrote:
>
> I find the :while modifier non intuitive
>
> user=> (for [x (range 1 10) y (range 1 10) :while (= y 2)] [x y])
> ()
> user=> (for [x (range 1 10) y (range 1 10) :while (= x 2)] [x y])
> ([2 1] [2 2] [2 3] [2 4] [2 5] [2 6] [2 7] [2 8] [2 9])
>
> My
I believe it stands for "member function". From the doc string:
"Expands into code that creates a fn that expects to be passed an
object and any args and calls the named instance method on the
object passing the args. Use when you want to treat a Java method as
a first-class fn."
On Mon,
Thanks John! Those suggestions are really helpful, the short-
circuiting 'and' is good to remember.
> Might simplify this a bit using assoc-in.
Yeah this works, nice, thanks.
(defn update-tile [[x y] maze value]
(if (tile-in-bounds? [x y] maze)
(assoc-in maze [y x] value)
maze))
Chee
I find the :while modifier non intuitive
user=> (for [x (range 1 10) y (range 1 10) :while (= y 2)] [x y])
()
user=> (for [x (range 1 10) y (range 1 10) :while (= x 2)] [x y])
([2 1] [2 2] [2 3] [2 4] [2 5] [2 6] [2 7] [2 8] [2 9])
My (false) intuition told me that both expressions would have be
Good Afternoon folks,
I am a newbie to Clojure, coming from CL, with very little Java
background.
I am trying to use the 'javax.persistence' libraries, but i just cant
seem to import it properly
for e.g
(import '(javax.persistence Persistence)
gives a
java.lang.ClassNotFoundException: javax.pers
Out of curiosity, does anyone know what memfn stands for? Is it an
abbreviation? Fn obviously stands for function. Mem calls to mind memoize,
but I'm not sure I see how memfn memoizes anything...
--~--~-~--~~~---~--~~
You received this message because you are subscr
Sorry about the copy&paste error. I partially changed len to cores.
The code must look like:
(defn maptest [cores] (doall (map (fn [x] (dotimes [_ 10]
(inc
0))) (range cores
(defn pmaptest [cores] (doall (pmap (fn [x] (dotimes [_ 10]
(inc 0))) (range cores
and
(defn mapt
Hi all,
recently I did some micro-benchmarks of parallel code on my 8-core
computer. But I don't get the point about this behaviour of pmap. Can
anyone explain this to me? The code is running on a dual quad-core
intel machine (Xeon X5482, 3.20 GHz).
(defn maptest [cores] (doall (map (fn [x] (dot
I think Mark's code exhibits a bug:
(def my-ref (ref 1))
(dosync
(ref-set my-ref 5)
(commute my-ref inc)) ; returns 6
(println "my-ref =" @my-ref) ; prints 7
since my-ref is ref-set, my-ref is in LockingTransaction/sets but its
current value in LockingTransaction/vals is set by commute to 6
51 matches
Mail list logo