Re: Generating special classes

2010-10-07 Thread mac
On Oct 6, 4:00 pm, Christian Vest Hansen karmazi...@gmail.com wrote: Actually... what I *really* want is your clj-native library :D Is this it?http://github.com/bagucode/clj-native Yes, that's it. :) I'm not actively working on it now but I will fix any errors reported so please just shoot

Is This Function Idiomatic Clojure?

2010-10-07 Thread Stefan Rohlfing
Dear Clojure Group, Following an Enlive tutorial I wanted to implement a function 'd-map' that takes an arbitrary number of [:key (list of values)] parameters like this: (d-map [:headline [this is me] ] [:points [1 2 3] ] [:comments [10 20 30] ]) and returns a

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Michael Gardner
On Oct 7, 2010, at 1:29 AM, Stefan Rohlfing wrote: Following an Enlive tutorial I wanted to implement a function 'd-map' that takes an arbitrary number of [:key (list of values)] parameters like this: (d-map [:headline [this is me] ] [:points [1 2 3] ] [:comments [10

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Per Vognsen
Try something like this: (defn dmap [ args] (for [[head items] args] item in items] [head item])) -Per On Thu, Oct 7, 2010 at 1:29 PM, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Dear Clojure Group, Following an Enlive tutorial I wanted to implement a function 'd-map'

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Per Vognsen
Your manual composition of concat and map is the same as the built-in function mapcat. Anyway, all this is what (for ...) does for you under the covers. -Per On Thu, Oct 7, 2010 at 1:52 PM, Michael Gardner gardne...@gmail.com wrote: On Oct 7, 2010, at 1:29 AM, Stefan Rohlfing wrote:

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Laurent PETIT
Hello, All in all, you only used in your first definition core clojure constructs, you avoided doing imperative in clojure clothes. So, while not leveraging to its full extent the power of clojure standard library functions and higher-order-functions, your code certainly qualifies as functional

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread David Sletten
On Oct 7, 2010, at 2:29 AM, Stefan Rohlfing wrote: Dear Clojure Group, Following an Enlive tutorial I wanted to implement a function 'd-map' that takes an arbitrary number of [:key (list of values)] parameters like this: (d-map [:headline [this is me] ] [:points [1 2 3] ]

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread nickikt
Thats what I came up with this. (defn getpairs [[key coll]] ;; split the key form the data (http:// blog.jayfields.com/2010/07/clojure-destructuring.html) (map (fn [x] [key x]) coll)) ;;put the key in front of every element in data (defn d-map [ colls] (mapcat getpairs colls)) ;;mapcat

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Stefan Rohlfing
Thank you all for your great code examples! The goal of the function 'd-map' is to return a collection of maps that looks like this: ({:headline this, :points 1, :comments 10} {:headline is, :points 2, :comments 20} {:headline me, :points 3, :comments 30}) Based on Per's example using

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Jason Wolfe
(defn d-map [ args] (apply map (fn [ vals] (zipmap (map first args) vals)) (map second args))) On Oct 7, 12:54 am, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Thank you all for your great code examples! The goal of the function 'd-map' is to return a collection of maps that

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Jason Wolfe
And I was about to post this variant ... looks very similar to yours :) (apply map merge (for [[k vs] args] (for [v vs] {k v}))) I think the crux is apply map... my go-to idiom for parallel iteration over an arbitrary number of seqs. On Oct 7, 1:26 am, Per Vognsen per.vogn...@gmail.com wrote:

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Meikel Brandmeyer
Hi, On 7 Okt., 08:29, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: (defn d-map [ kfps]   (let [keys     (map first kfps)          fns       (map second kfps)]     (loop [keys keys fns fns res []]       (if (seq keys)         (recur (rest keys) (rest fns)                    (into res

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Stefan Rohlfing
Thanks again for these beautiful code examples! I haven't come across (apply map ... before so this is idiom a big step forward for me. The same is true for the extended use of 'reduce'. I know that this function is really powerful but I am only just beginning to understand its potential.

Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference

2010-10-07 Thread Patrik Hedman
2010/10/6 Cédric Pineau cedric.pin...@gmail.com Looks nice indeed ! Very REST oriented, isn't it ? Thank you :) Yes, I try to keep it as RESTful as possible One thing : I'm new to clojure and gathering information about the whole ecosystem, including web frameworks, but find it hard to

Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Jarl Haggerty
Problem 14 on project Euler is to find the number under 1,000,000 that is the start of the longest Collatz sequence. My solution is below, basically it uses a hash map to cache the lengths of collatz sequences. But when I get to 113383 the collatz function just bounces between the numbers 1, 2,

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Stuart Halloway
Which version of Clojure are you running? The most likely cause of this problem is having a mix of numeric types (e.g. longs and ints) as keys/key lookups in a hash map. This is broken as required (sigh) by Java collections. Clojure 1.3 improves the story by having Clojure's collections defy

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Ulises
My take on this. I know it's convoluted, I know this is probably not the best and not even a good-enough solution, but it's what I have so far (needless to say, I'd welcome comments on my code :) (defn explode [ [k vals ] ] (map #(vector key %) vals)) (defn update-map [ m ] (partial apply assoc

Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference

2010-10-07 Thread Cédric Pineau
That's make things clearer to me, and especially James' summary which is simple when exposed but time-consuming to figure out by yourself :-) As for Flash, I've never met such thing in my everyday java world, but it's a nice idea. Thanks to all of you ! -- Cédric -- You received this

Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference

2010-10-07 Thread Jacek Laskowski
2010/10/7 Cédric Pineau cedric.pin...@gmail.com: As for Flash, I've never met such thing in my everyday java world, but it's a nice idea. The flash scope is quite popular in web frameworks like Seam Framework or Grails (which I believe inherited it from Spring MVC). It then popped up in other

Clojure + Swank + Slime + OSX

2010-10-07 Thread pete.m
Hello, I'm having a hard time getting Clojure 1.2/swank-clojure 1.3/leiningen 1.3.1/slime working on my Macbook (10.5.8). I can create a new project with 'lein new Project', but when I add the dev-dependency for swank-clojure, and try to run lein deps on the project, I get some exceptions

Re: Clojure + Swank + Slime + OSX

2010-10-07 Thread Phil Hagelberg
You've got the syntax for dev-dependencies wrong; swank should be a vector inside a vector. But if you're on leiningen 1.3.1 anyway you can just place the swank jar in ~/.lein/plugins to make it available to all projects without touching project.clj. -Phil On Oct 7, 2010 6:53 AM, pete.m

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Miki
FWIW: I've used the built in memoize and had not problem. You can view my solution at http://bitbucket.org/tebeka/euler-clj/src/tip/14.clj On Oct 6, 10:46 pm, Jarl Haggerty fictivela...@gmail.com wrote: Problem 14 on project Euler is to find the number under 1,000,000 that is the start of the

Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference

2010-10-07 Thread Sean Corfield
2010/10/7 Cédric Pineau cedric.pin...@gmail.com: As for Flash, I've never met such thing in my everyday java world, but it's a nice idea. It's pretty standard in web frameworks. I see it in nearly every MVC framework in CFML and Grails / Rails do it too - as well as several Java web frameworks.

Clojusre's got a lot of coolness about it but it's not for everyone.

2010-10-07 Thread 386sx
http://www.basementcoders.com/transcripts/James_Gosling_Transcript.html Moderator: What's your thoughts on the other languages? James Gosling: I'm a big fan. I can't say I use them a lot. You know, the Java design was not that I thought it was the perfect language. The whole design concept there

Re: Clojusre's got a lot of coolness about it but it's not for everyone.

2010-10-07 Thread nickikt
Was posted already. On 7 Okt., 18:12, 386sx ng8038...@gmail.com wrote: http://www.basementcoders.com/transcripts/James_Gosling_Transcript.html Moderator: What's your thoughts on the other languages? James Gosling: I'm a big fan. I can't say I use them a lot. You know, the Java design was

Re: Clojure + Swank + Slime + OSX

2010-10-07 Thread pete.m
You are correct sir! That was the problem. Thanks for the tip on the plugin folder too. -pete- On Oct 7, 11:18 am, Phil Hagelberg p...@hagelb.org wrote: You've got the syntax for dev-dependencies wrong; swank should be a vector inside a vector. But if you're on leiningen 1.3.1 anyway you can

Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference

2010-10-07 Thread Patrik Hedman
Yes, this is by no means unique to funkyweb. In fact, under the hood it uses the flash middleware provided by ring which is available to all ring based framework. Cheers - Patrik 2010/10/7 Sean Corfield seancorfi...@gmail.com 2010/10/7 Cédric Pineau cedric.pin...@gmail.com: As for Flash,

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Mark Engelberg
On Thu, Oct 7, 2010 at 4:21 AM, Stuart Halloway stuart.hallo...@gmail.com wrote: Which version of Clojure are you running? The most likely cause of this problem is having a mix of numeric types (e.g. longs and ints) as keys/key lookups in a hash map. This is broken as required (sigh) by

Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference

2010-10-07 Thread Cédric Pineau
Flash just can't be so wide spread in the java world. No it can't. It does ??? Oh please, please !!.. ok shame on me :-/ ! Cédric, learning java stuff on clojure's mailing lists :-) ! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Jarl Haggerty
I was using 1.2, I thought I posted that here but I don't see the message. I don't have the same problem in 1.3, but I have some slightly tangental questions. 1. How do I get leiningen to use 1.3 when I type lein repl, right now I have to compile a jar and execute it if I want to use the 1.3

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Jarl Haggerty
I try not to post twice in a row but I thought it was rude of me not to say thanks for the help. On Oct 7, 7:42 pm, Jarl Haggerty fictivela...@gmail.com wrote: I was using 1.2, I thought I posted that here but I don't see the message.  I don't have the same problem in 1.3, but I have some

Re: New Release of the Clojure Debugging Toolkit

2010-10-07 Thread limux
where is the sa-jdi.jar, there isn't the sa-jdi.jar under my java's lib directory. On 9月29日, 下午12时00分, George Jahad cloj...@blackbirdsystems.net wrote: hmmm, you must be as big a debugger geek as I am, but I'm not sure anyone else would be interested. In any case the commands are almost

Re: Project Euler problem 14: Maybe it's me but hash maps don't seem to work

2010-10-07 Thread Sean Corfield
On Thu, Oct 7, 2010 at 7:42 PM, Jarl Haggerty fictivela...@gmail.com wrote: 1.  How do I get leiningen to use 1.3 when I type lein repl, right now I have to compile a jar and execute it if I want to use the 1.3 library. Specify these dependencies: :dependencies [[org.clojure/clojure

Re: evaluation of a function via mathematica from clojure using the clojuratica bridge...

2010-10-07 Thread Garth Sheldon-Coulson
Hi Sunil, Double check that you have the .m files from the Clojuratica distribution in your Mathematica $Path. The error message you received makes me think that the file ClojurianScopes.m is not being properly loaded by Mathematica/Clojuratica. You can check this by firing up Mathematica and

Re: evaluation of a function via mathematica from clojure using the clojuratica bridge...

2010-10-07 Thread Garth Sheldon-Coulson
Sorry, the Needs call isn't quite right. Do this instead: ClojurianScopes` Garth On Fri, Oct 8, 2010 at 12:23 AM, Garth Sheldon-Coulson g...@mit.edu wrote: Hi Sunil, Double check that you have the .m files from the Clojuratica distribution in your Mathematica $Path. The error message you