Re: A question regarding map destructuring

2010-11-02 Thread Mike Meyer
On Mon, 1 Nov 2010 23:41:47 -0700 (PDT) Meikel Brandmeyer wrote: > Hi, > > On 2 Nov., 03:25, Mike K wrote: > > > (print-value-a [:b 7 :a 3]) > > ; actually prints nil > > You have to use apply. (apply print-value-a [:b 7 :a 3]). > > Furthermore: how could (let [{a :a} [:b 7 :a 3]] [a]) possi

Re: defmethod hangs

2010-11-02 Thread Jarl Haggerty
Thanks for look, I figured it was unlikely anyone could give me a solution, but it was late at night, clojure wasn't telling me anything, and I was kind of burnt out. I've been experimenting and trying to replicate the problem in a smaller program but all I've learned is that if I move the functio

Re: A question regarding map destructuring

2010-11-02 Thread Meikel Brandmeyer
Hi, On 2 Nov., 08:14, Mike Meyer wrote: > This only happens if the rest argument destructuring is a hash map - > if I use a vector or a symbol there, then the values don't get turned > into a map. Can't that same mechanism be used in the case where some > non-rest argument is a hash-map trying t

Re: defmethod hangs

2010-11-02 Thread Jarl Haggerty
I don't know if it's of any worth but I switched from 1.3.0-alpha2- SNAPSHOT to 1.2 and my problems are gone. The simplest way I found to reproduce the error I was having in 1.3 was to paste this following function into a repl. The function is meaningless but I figure it should at least compile.

monads m-seq and m-lift

2010-11-02 Thread Sunil S Nandihalli
Hello everybody, I was looking at the functions/macros defined with them I find that m-lift is very easy and intuitive .. following is the extract from the monads example ... (with-monad sequence-m (defn pairs [xs] ((m-lift 4 #(list :a %1 :b %2 :c %3 :d %4)) (range 0 3) (ra

Re: monads m-seq and m-lift

2010-11-02 Thread nicolas.o...@gmail.com
As I understand it, m-seq is transforms a list of monadic computation into a computation returning the list of result. The resulting computation just sequentially does every computationin the sequence and keep the result. It is useful when the arity is not known at runtime foir example. On Tue,

Meta-circular STM for teaching purposes

2010-11-02 Thread Tom Van Cutsem
Hi, In a couple of months I will teach a new course on concurrent/parallel programming at the University of Brussels. I will use Clojure for a large part of the course. I primarily want the students to learn how to make effective use of the STM as Clojure programmers, but I would also like to expo

Re: monads m-seq and m-lift

2010-11-02 Thread Konrad Hinsen
On 02.11.2010, at 11:45, Sunil S Nandihalli wrote: > following is the extract from the monads example ... It looks quite modified and no longer returns pairs! Here is the original: (with-monad sequence-m (defn pairs [xs] ((m-lift 2 #(list %1 %2)) xs xs))) > ; Another way to define pair

Re: monads m-seq and m-lift

2010-11-02 Thread Ken Wesson
On Tue, Nov 2, 2010 at 7:58 AM, Konrad Hinsen wrote: > On 02.11.2010, at 11:45, Sunil S Nandihalli wrote: > > > following is the extract from the monads example ... > > It looks quite modified and no longer returns pairs! Here is the original: > > (with-monad sequence-m > (defn pairs [xs] >

Re: monads m-seq and m-lift

2010-11-02 Thread Konrad Hinsen
On 02.11.2010, at 13:34, Ken Wesson wrote: > This wouldn't work?: > > (with-monad sequence-m > (defn ntuples [n xs] > (apply (m-lift n list) (replicate n xs No. > (If m-lift is a macro that requires the arity arg to be known at > macroexpansion time: > > (with-monad sequence-m >

Re: figuring out sets

2010-11-02 Thread tonyl
Wow, this brings more light to the subject. Thank you guys for your explanations and practical uses. On Nov 2, 1:31 am, Rasmus Svensson wrote: > 2010/11/1 tonyl : > > > I was wondering since it uses the dispatch macro and AFAIK > > there is no api fn to create them like hash-maps to create maps,

Re: monads m-seq and m-lift

2010-11-02 Thread Ken Wesson
On Tue, Nov 2, 2010 at 8:55 AM, Konrad Hinsen wrote: > On 02.11.2010, at 13:34, Ken Wesson wrote: > > > This wouldn't work?: > > > > (with-monad sequence-m > > (defn ntuples [n xs] > > (apply (m-lift n list) (replicate n xs > > No. > > > (If m-lift is a macro that requires the arity arg

A question on distributed computing

2010-11-02 Thread Vivek Khurana
Hi! I am currently developing an application where I need to enforce certain policy on clojure code. My requirement is that code+data can be sent to a remote node and based on certain access control and config, one should be able to control whether the remote node is allowed to execute code or ha

Re: monads m-seq and m-lift

2010-11-02 Thread Sunil S Nandihalli
Hi Konrad, nicolas and Ken, Thanks for help. I am sure I will need more help when I try to walk through the rest of the examples. But the idea of monads is really neat..:).. Sunil. On Tue, Nov 2, 2010 at 7:19 PM, Ken Wesson wrote: > On Tue, Nov 2, 2010 at 8:55 AM, Konrad Hinsen > wrote: > >

Re: A question on distributed computing

2010-11-02 Thread Ken Wesson
On Tue, Nov 2, 2010 at 11:03 AM, Vivek Khurana wrote: > Hi! > > I am currently developing an application where I need to enforce > certain policy on clojure code. My requirement is that code+data can > be sent to a remote node and based on certain access control and > config, one should be able t

Re: A question on distributed computing

2010-11-02 Thread Sunil S Nandihalli
Hi Vivek, Well you could cryptographically sign the data and check the signature in case you want to verify that the data was not modified.. and you should require all the nodes to sign the data that they modify and make sure that no node accepts data that is not signed.. Just an idea.. I have not

Re: From jetty to war?

2010-11-02 Thread Luke VanderHart
fanvie, two comments: 1. It will get better over time, of course, as standard practices for Clojure shake out. 2. You don't need 99% of the special crap that Spring/Grails gives you. Clojure's abstractions are smaller, yes, but the're just as powerful, and give you more control, in a more standard

Re: figuring out sets

2010-11-02 Thread Alan
Except when they are small enough to conveniently be array-maps: user=> (class (into {} (zipmap (range) (range 8 clojure.lang.PersistentArrayMap user=> (class (into {} (zipmap (range) (range 9 clojure.lang.PersistentHashMap But those behave just like hash-maps, so you can ignore the diffe

Re: to macro or not?

2010-11-02 Thread Laurent PETIT
2010/10/30 Tim Daly : >  Macros in lisp get used for three general purposes, at least > in my experience. > > The first purpose is efficiency. In common lisp you will find > that you can generate very machine-efficient (aka optimized > fortran level) binary instruction sequences if you add type > i

Re: to macro or not?

2010-11-02 Thread Ken Wesson
On Tue, Nov 2, 2010 at 1:38 PM, Laurent PETIT wrote: > 2010/10/30 Tim Daly : > > Macros in lisp get used for three general purposes, at least > > in my experience. > > > > The first purpose is efficiency. In common lisp you will find > > that you can generate very machine-efficient (aka optimized

Re: From jetty to war?

2010-11-02 Thread Wilson MacGyver
On Tue, Nov 2, 2010 at 12:49 PM, Luke VanderHart wrote: > fanvie, two comments: > 2. You don't need 99% of the special crap that Spring/Grails gives > you. Clojure's abstractions are smaller, yes, but the're just as > powerful, and give you more control, in a more standardized way, then > Spring d

Re: to macro or not?

2010-11-02 Thread Meikel Brandmeyer
Hi, Am 02.11.2010 um 18:46 schrieb Ken Wesson: > http://speakerrate.com/talks/4895-not-dsl-macros The link works perfectly for me in firefox. No discrimination stupidity here... Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread Rick Mouritzen
Los Angeles Clojure Users Group http://clj-la.org/ On Sat, Oct 30, 2010 at 7:38 PM, Alex Miller wrote: > Hi all, > > I'm doing a bit of doc cleanup on http://clojure.org and I'd welcome > your feedback on things that are broken or could be improved. I'm not > looking (or likely authorized :) to

Re: to macro or not?

2010-11-02 Thread Ken Wesson
On Tue, Nov 2, 2010 at 2:49 PM, Meikel Brandmeyer wrote: > Hi, > > Am 02.11.2010 um 18:46 schrieb Ken Wesson: > > > http://speakerrate.com/talks/4895-not-dsl-macros > > The link works perfectly for me in firefox. No discrimination stupidity > here... > Yeah, that's weird. It seems to have been d

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread Kyle R. Burton
>> I'm particularly interested in: >> - new user groups or suggestions for the community page >> - stuff that is just wrong or out of date Philly Clojure Language Club: http://groups.google.com/group/phl-clojure-language-club Kyle -- Twitter: @kyleburton Blog: http://asymmetrical-view.com/ Fun:

Re: From jetty to war?

2010-11-02 Thread lprefontaine
Luke, I must agree with Wilson, other frameworks have some advantages presently over Clojure for certain tasks. We use RAILS and JRuby to create CRUD GUIs with ActiveScaffold. Our controllers are typically 20 lines or less of configuration statements... We do not need to maintain HTML templates e

[Bug] StackOverflowError while using map inside a reduce

2010-11-02 Thread Pepijn de Vos
Hi all, Usually my 'bugs' are in my own code, but this time I talked to three of four people on IRC and came up with a one-liner that suffers the same problem my project has. I was optimizing some code to not retain the head of the sequence, but when I put a map inside a reduce over a gigantic

Resources on optimizing Clojure code

2010-11-02 Thread Dan Kefford
Hello fellow clojurians... I've been using Clojure now fairly regularly for the past two months solving problems on Project Euler. I've been fairly successful solving them but there are times where the performance of my code either stinks (the answer may come back in 5-10 minutes) or not at all ev

Re: A suggestion for the next Conj

2010-11-02 Thread Roger Austin (@RogerTheGeek)
At NCDevCon, we had sessions that were hands-on where the attendees could bring their laptop and get completely set up with their programming environment and tools. Plus, an expert gave a demo on how to get started and an overview. Usually, they were half day or full day sessions. That could be an

Re: [Bug] StackOverflowError while using map inside a reduce

2010-11-02 Thread Meikel Brandmeyer
Hi, Am 02.11.2010 um 12:58 schrieb Pepijn de Vos: > The one-liner: > http://gist.github.com/659491 I would expect this is because you pile lazy seq on lazy seq, which then get realised, unfolding the whole thing resulting in the stack overflow. Try this: user=> (reduce #(doall (map + %1 %2)) (

Re: Resources on optimizing Clojure code

2010-11-02 Thread Alan
Usually it's more about the algorithm than the language. Java can generally do things faster than clojure, simply because it has fewer layers, but the speedup is a linear factor. If the java solution for 1000 elements takes 5ms and your clojure code takes even a second, it's likely that clojure isn

Re: Resources on optimizing Clojure code

2010-11-02 Thread David Andrews
Yes, on the handful of Project Euler exercises I've attempted, my algorithm choice was frequently the source of poor performance. Are you familiar with the clojure-euler wiki at http://clojure-euler.wikispaces.com/ ? After I do an Euler exercise I compare my code and runtime with other Clojure s

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread Jason Wolfe
Not sure if you count this as off limits as part of the API page, but its first line points to a stale "official source code for clojure" -- should be updated to the new github repo. -Jason On Oct 30, 7:38 pm, Alex Miller wrote: > Hi all, > > I'm doing a bit of doc cleanup onhttp://clojure.organ

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread Alex Miller
- Jeff, Rick, Kyle - I've added your groups - added other groups mentioned on #clojure and twitter - cheat sheet has been updated to 1.2 - new "tips on starting a user group" page added - http://clojure.org/start_group (linked from the community page) - fixed broken links on contributing page - fi

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread Michael Wood
This is perhaps a little off topic, but related. I see that http://code.google.com/p/clojure/ has been updated recently, but still references Assembla. These could do with an update too: http://sourceforge.net/projects/clojure/ http://sourceforge.net/projects/clojure-contrib/ -- Michael Wood

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread Alex Miller
Jason - that's a good catch but out of my purview. Also, those are autodocs generated from the (released and thus immutable :) 1.2 afaik. On Nov 2, 4:12 pm, Jason Wolfe wrote: > Not sure if you count this as off limits as part of the API page, but > its first line points to a stale "official so

Re: [Bug] StackOverflowError while using map inside a reduce

2010-11-02 Thread John Szakmeister
On Tue, Nov 2, 2010 at 4:49 PM, Meikel Brandmeyer wrote: > Hi, > > Am 02.11.2010 um 12:58 schrieb Pepijn de Vos: > >> The one-liner: >> http://gist.github.com/659491 > > I would expect this is because you pile lazy seq on lazy seq, which then get > realised, unfolding the whole thing resulting in

Re: [Bug] StackOverflowError while using map inside a reduce

2010-11-02 Thread Rasmus Svensson
2010/11/3 John Szakmeister : > I'm sorry... I don't quite understand this explanation.  Do you mean > that reduce is realizing the entire list all at once?  I would think > it would grab an element one at a time.  Sorry for the stupid > question, but there's something subtle here that I'm not > und

Java gotchas now clojure gotchas

2010-11-02 Thread box
Math/abs doesn't always return positive numbers. example: user=> (def min-int -2147483648) #'user/min-int user=> min-int -2147483648 user=> (Math/abs min-int) -2147483648 user=> (def min-int+1 (+ 1 min-int)) #'user/min-int+1 user=> min-int+1 -2147483647 user=> (Math/abs (- min-int+1 1)) -214

Re: From jetty to war?

2010-11-02 Thread Chris Riddoch
On Tue, Nov 2, 2010 at 10:49 AM, Luke VanderHart wrote: > fanvie, two comments: > > 1. It will get better over time, of course, as standard practices for > Clojure shake out. > 2. You don't need 99% of the special crap that Spring/Grails gives > you. Clojure's abstractions are smaller, yes, but th

Re: Java gotchas now clojure gotchas

2010-11-02 Thread CuppoJava
Personally, I find the added time and complexity required to be careful about such problems (ie. numerical overflow) is easier to deal with than later having to optimize subtle performance problems that arise from these automatic boxing / upcasting solutions. From the frequency of performance-relat

Re: Java gotchas now clojure gotchas

2010-11-02 Thread Sean Corfield
On Tue, Nov 2, 2010 at 3:22 PM, box wrote: > Math/abs doesn't always return positive numbers. example: Have you tried this on 1.3.0-master-SNAPSHOT? user=> (def min-int -2147483648) #'user/min-int user=> (Math/abs min-int) 2147483648 user=> (def min-int+1 (+ 1 min-int)) #'user/min-int+1 user=> m

Re: Java gotchas now clojure gotchas

2010-11-02 Thread Benny Tsai
Have you checked out clojure-contrib.math's abs function? It appears to do the right thing for the cases you listed. On Nov 2, 4:22 pm, box wrote: > Math/abs doesn't always return positive numbers. example: > > user=> (def min-int -2147483648) > #'user/min-int > > user=> min-int > -2147483648 >

Re: Java gotchas now clojure gotchas

2010-11-02 Thread ataggart
In a two's-complement system, values always have one more negative number than positive number. -2147483648 (being the most negative int) has no positive equivalent that can be expressed as an int (Math/abs overloads on primitive type). Sean's example using 1.3.0-SNAPSHOT works because literal num

Re: Java gotchas now clojure gotchas

2010-11-02 Thread box
this is on clojure 1.1 (current ubuntu stable rep) so, the code below shows ABS returning 2 different values for the 'same' input in clojure. input being Integer.MIN_VALUE. of course one input is an int and the other is a bigint, but we can't see the difference in clojure, and as the code shows at

Re: From jetty to war?

2010-11-02 Thread lprefontaine
Ahem.. Your comment misses the point. We chose RAILS because it met 90% of our needs... not because of some claims it would solve any problem. We then selected RAILS over Grails then based on the time it required us to code, the # of code lines was a very good measure then to make our final sel

Re: Java gotchas now clojure gotchas

2010-11-02 Thread Paul Iannazzo
user=> (Math/abs (- Long/MIN_VALUE 1) this hung my clojure repl, clojure 1.1 ~~ Paul Joseph Iannazzo. On Tue, Nov 2, 2010 at 10:09 PM, ataggart wrote: > In a two's-complement system, values always have one more negative > number than positive number. -2147483648 (being the most negative int)

Re: Java gotchas now clojure gotchas

2010-11-02 Thread box
sorry, i wrote too soon. (Math/abs (- Long/MIN_VALUE 1)) java.lang.IllegalArgumentException: No matching method found: abs (NO_SOURCE_FILE:0) so, maybe this is a good time to start a clojure math library. or at least have some warning when using math libs in clojure. On Nov 2, 10:32 pm, Paul Ian

Re: Java gotchas now clojure gotchas

2010-11-02 Thread Mark Engelberg
On Tue, Nov 2, 2010 at 7:35 PM, box wrote: > so, maybe this is a good time to start a clojure math library. or at > least have some warning when using math libs in clojure. To reiterate what was said earlier in this thread, clojure.contrib.math extends basic math functionality to Clojure's full n

Re: Java gotchas now clojure gotchas

2010-11-02 Thread box
http://richhickey.github.com/clojure-contrib/math-api.html i just found this. i guess i wasn't paying attention because i didn't see it stated before as a solution. thank you. On Nov 2, 10:45 pm, Mark Engelberg wrote: > On Tue, Nov 2, 2010 at 7:35 PM, box wrote: > > so, maybe this is a good t

Re: Java gotchas now clojure gotchas

2010-11-02 Thread Benny Tsai
The latest API is here: http://clojure.github.com/clojure-contrib/math-api.html On Nov 2, 8:50 pm, box wrote: > http://richhickey.github.com/clojure-contrib/math-api.html > > i just found this. > > i guess i wasn't paying attention because i didn't see it stated > before as a solution. > > thank

Re: Java gotchas now clojure gotchas

2010-11-02 Thread Sean Corfield
On Tue, Nov 2, 2010 at 7:35 PM, box wrote: > sorry, i wrote too soon. > > (Math/abs (- Long/MIN_VALUE 1)) > java.lang.IllegalArgumentException: No matching method found: abs > (NO_SOURCE_FILE:0) On 1.3.0: user=> (Math/abs (- Long/MIN_VALUE 1)) ArithmeticException integer overflow clojure.lang.Nu

Re: REQUEST for feedback on http://clojure.org

2010-11-02 Thread ka
Hi Alex, Can we have a section: Clojure - What's next? Dishes out some details & links for the next versions and ideas. -- 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

Re: From jetty to war?

2010-11-02 Thread Sean Corfield
On Tue, Nov 2, 2010 at 7:26 PM, wrote: > Doing the reverse is non sense (choosing a framework based on some hyped > reviews and then use for every need). ... > We cannot rewrite the whole universe in Clojure in one year. That's a fact. > It's improving but will take some time to cover a number of

Re: monads m-seq and m-lift

2010-11-02 Thread Sunil S Nandihalli
yea .. I was playing around and modified it in the due coarse.. :) Sunil. On Tue, Nov 2, 2010 at 5:28 PM, Konrad Hinsen wrote: > On 02.11.2010, at 11:45, Sunil S Nandihalli wrote: > > > following is the extract from the monads example ... > > It looks quite modified and no longer returns pairs! H

Re: A question on distributed computing

2010-11-02 Thread Vivek Khurana
On Nov 2, 8:56 pm, Ken Wesson wrote: > That seems impossible assuming you don't trust the software running on the > other node. > It is not impossible. There are projects by Cornell .University, jiff[1] and fabric[2] which have achieved the same. Jiff is modification of java and fabric is bas

clojure-backtracking-monads .. can it emulate prolog?

2010-11-02 Thread Sunil S Nandihalli
Hello everybody, I was wondering if one can code in a way semantically similar to prolog using the backtracking monads.. Has anybody tried it .. ? I did see the tutorial which demonstrates backtracking monads .. http://brehaut.net/blog/2010/ghosts_in_the_machine it is nice .. I have to look at it

Re: StackOverflowError while using map inside a reduce

2010-11-02 Thread Meikel Brandmeyer
Hi, On 3 Nov., 00:40, Rasmus Svensson wrote: > I think the problem is that this reduction will build an expression like this: > >     (map + ... (map + ... (map + ... (map + ... levels> > > When clojure tries to realize an element of the resulting lazy seq, > every level will result in a ne