Re: How to use params in java?

2011-04-03 Thread Meikel Brandmeyer
Hi, here an example step-by-step: import clojure.lang.RT; import clojure.lang.IPersistentVector; import clojure.lang.PersistentVector; import clojure.lang.Keyword; public class SomeClass { public static void main(String[] args) { Var prn = RT.var("clojure.core", "prn"); Keyw

Re: How to use params in java?

2011-04-03 Thread monyag
I don't need concrete example with vijual, I don't understand how to use this parameters whatever vijual -( Thanks for the help, Armando, I'm trying do this. On 4 апр, 06:07, Armando Blancas wrote: > I don't have any examples; using a Clojure lib like that is a real > pain. As you can see, intero

Re: April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread Carin Meier
Nice. Thanks. It is also interesting now to see the graphical difference in running send-off vs send for my raindrops. send gives me a nice drizzle, while send-off gives me a sudden downpour :) On Apr 3, 9:29 pm, Alan wrote: > I'd write it as (repeatedly num-raindrops #(agent nil)). > > On Apr

Re: April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread Alan
I'd write it as (repeatedly num-raindrops #(agent nil)). On Apr 3, 5:27 pm, Sean Corfield wrote: > On Sun, Apr 3, 2011 at 4:31 PM, carinmeier wrote: > >  (let [rainagents (vec (repeat num-raindrops (agent nil)))] > > Wouldn't that create a vector with N copies of the same agent? > > Try: > > (le

Re: April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread carinmeier
You are exactly right! Thank you! On Apr 3, 8:27 pm, Sean Corfield wrote: > On Sun, Apr 3, 2011 at 4:31 PM, carinmeier wrote: > >  (let [rainagents (vec (repeat num-raindrops (agent nil)))] > > Wouldn't that create a vector with N copies of the same agent? > > Try: > > (let [rainagents (vec (ma

Re: April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread Sean Corfield
On Sun, Apr 3, 2011 at 4:31 PM, carinmeier wrote: >  (let [rainagents (vec (repeat num-raindrops (agent nil)))] Wouldn't that create a vector with N copies of the same agent? Try: (let [rainagents (vec (map agent (repeat num-raindrops nil)))] >    (dorun >     (pmap >      #(send-off % draw-rai

Re: April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread carinmeier
Ken, Yes, I have separate agents for the raindrops and I am using send- off ... Here is the code bit: (defn make-it-rain [g num-raindrops] (let [rainagents (vec (repeat num-raindrops (agent nil)))] (dorun (pmap #(send-off % draw-raindrop-fall g (rand-nth (range 0 500))) rai

Re: Clojure Code Highlighting in Presentations

2011-04-03 Thread Miki
Greetings, not a clojure technical question but it has to do with the entire topic :). > I know there have been some presentations about clojure already and would > like to ask for some best practice experience regarding embedding Clojure > code in a presentation. Any advice? What tools did you

Re: Clojure Code Highlighting in Presentations

2011-04-03 Thread Meikel Brandmeyer
Hi, Am 03.04.2011 um 18:15 schrieb Heinz N. Gies: > not a clojure technical question but it has to do with the entire topic :). I > know there have been some presentations about clojure already and would like > to ask for some best practice experience regarding embedding Clojure code in > a pr

Re: April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread Ken Wesson
On Sun, Apr 3, 2011 at 5:10 PM, carinmeier wrote: > I am experimenting with Java Graphics and Clojure.  I made a Gist that > draws a frame with some text, grass and raindrops falling.  I made a > function that draws a raindrop falling and I created agents to send > off the drawing of the raindrop.

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Ken Wesson
On Sun, Apr 3, 2011 at 8:45 AM, Roman Sykora <4rt.f...@gmail.com> wrote: > Now, my question is what's the improvement of > >> (defn take-by [f coll] >>   (let [fs (map f coll) >>          ps (map = fs (rest fs)) >>          zs (map #(if %1 %2 sentinel) ps (rest coll))] >>     (cons (first coll) (ta

April Showers Bring May Flowers - raindrop advice please

2011-04-03 Thread carinmeier
I am experimenting with Java Graphics and Clojure. I made a Gist that draws a frame with some text, grass and raindrops falling. I made a function that draws a raindrop falling and I created agents to send off the drawing of the raindrop. I then called pmap to send-off the agents to the draw-rai

Re: How to use params in java?

2011-04-03 Thread Armando Blancas
I don't have any examples; using a Clojure lib like that is a real pain. As you can see, interop to Java doesn't just happens but it must be designed into a library. You may want to consider adding an interop layer on top that vijual thingy or use plain scripting for everything and not use invoke.

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Alan
I like your version, Roman. It seems as efficient as anything, and is easy to read. For what it's worth, I'd make a small rewrite: (defn take-by [f coll] (lazy-seq (when-let [[x & xs] (seq coll)] (let [val (f x)] (cons x (take-while (comp #{val} f) xs)) On Apr 3, 5:45 am, Rom

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Roman Sykora
Hi When I read this post in the morning I thought about how I would implement this function, and the result was: (defn take-by [f coll] (when-let [[x & xs] (seq coll)] (let [n (f x)] (lazy-seq (cons x (take-while #(= n (f %)) xs)) I didn't post it, because I really am a beginne

Re: Example to introspect a class

2011-04-03 Thread Mushfaque Chowdhury
Thank you I'm still learning all the different forms so this is very helpful. On Apr 1, 10:13 pm, Ken Wesson wrote: > On Fri, Apr 1, 2011 at 10:56 AM, Mushfaque Chowdhury > > > > > > > > > > wrote: > > Hi > > > I'm trying to solve a introspection problem of the following type > > > (def Regio

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Andreas Kostler
There you go, symmetry and simplicity :) On 04/04/2011, at 6:35 AM, Alan wrote: > Isn't all this just a special case of partition-by? > > (defn drop-by [f coll] > (apply concat (rest (partition-by f coll > > (defn take-by [f coll] > (first (partition-by f coll))) > > user> (drop-by (part

bug report : cl-format

2011-04-03 Thread Carlos Ungil
Hello, I don't know if there is a better way to file bug reports (if there is one, it's not easy to find). (use 'clojure.pprint) (let [x 111.1] (doseq [fmt ["~3f~%" "~4f~%" "~5f~%" "~6f~%"]] (cl-format true fmt x))) ;; 111.1 ;; 111.1 ;; 111.1 ;; 111.11 There is clearly a pro

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Alan
Isn't all this just a special case of partition-by? (defn drop-by [f coll] (apply concat (rest (partition-by f coll (defn take-by [f coll] (first (partition-by f coll))) user> (drop-by (partial + 2) [2 2 2 3 3 4]) (3 3 4) user> (take-by #(mod % 3) [1 4 1 7 34 16 10 2 99 103 42]) (1 4 1 7

Re: using clojure for (java) code generation; advice sought

2011-04-03 Thread B Smith-Mannschott
On Fri, Apr 1, 2011 at 22:18, B Smith-Mannschott wrote: > On Wed, Mar 30, 2011 at 15:00, Stuart Sierra > wrote: >> Take a look at http://www.stringtemplate.org/ for a Turing-complete, >> purely-functional, Java-based template language designed for code >> generation. > Well, I've spent the weeke

Re: Clojure Code Highlighting in Presentations

2011-04-03 Thread Shantanu Kumar
On Apr 3, 9:15 pm, "Heinz N. Gies" wrote: > Hi everyone, > not a clojure technical question but it has to do with the entire topic :). I > know there have been some presentations about clojure already and would like > to ask for some best practice experience regarding embedding Clojure code in

Re: How to use params in java?

2011-04-03 Thread monyag
Hello, Armando! do you can give me short example? I have some RuntimeExaptions :( On 3 апр, 01:31, Armando Blancas wrote: > You need to use a few more classes from jvm/clojure/lang. For example, > with PersistentVector#create(Object...) and one of the > Keyword#intern() calls you should be ab

Re: Clojure Code Highlighting in Presentations

2011-04-03 Thread Mike Meyer
On Sun, 3 Apr 2011 18:15:43 +0200 "Heinz N. Gies" wrote: > Hi everyone, > not a clojure technical question but it has to do with the entire topic :). I > know there have been some presentations about clojure already and would like > to ask for some best practice experience regarding embedding C

Clojure Code Highlighting in Presentations

2011-04-03 Thread Heinz N. Gies
Hi everyone, not a clojure technical question but it has to do with the entire topic :). I know there have been some presentations about clojure already and would like to ask for some best practice experience regarding embedding Clojure code in a presentation. Any advice? What tools did you peop

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Meikel Brandmeyer
Hi, On 3 Apr., 13:18, Ken Wesson wrote: > "Less" involved? Your solution combines 5 sequences with drop-while-first-map-second magic which I personally don't find very self-explaining at first sight. My solution does one step with only local impact and then delegates to a single well-known libr

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Ken Wesson
On Sun, Apr 3, 2011 at 7:15 AM, Meikel Brandmeyer wrote: > Hi, > > On 3 Apr., 12:24, Ken Wesson wrote: > >> I don't. :) >> >> (defn drop-by [f coll] >>   (let [fs (map f coll) >>         ps (map = fs (rest fs)) >>         zs (map list ps (rest coll))] >>     (map second (drop-while first zs >

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Meikel Brandmeyer
Hi, On 3 Apr., 12:24, Ken Wesson wrote: > I don't. :) > > (defn drop-by [f coll] >   (let [fs (map f coll) >         ps (map = fs (rest fs)) >         zs (map list ps (rest coll))] >     (map second (drop-while first zs > > user=> (drop-by #(mod % 3) [1 4 1 7 34 16 10 2 99 103 42]) > (2 99 1

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Ken Wesson
On Sun, Apr 3, 2011 at 3:23 AM, Stefan Rohlfing wrote: > @ Ken, Andreas > > Thank you for your nice implementations! > > As far as I can see, there are two main methods of comparing adjacent items > of a list: > > 1) Take the first item of a coll. Compare the remaining items with an offset > of 1:

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Stefan Rohlfing
Hi Andreas, You are right, the helpful Clojure community is a real asset to be proud of! I like your solution using* loop ... recur* as it makes the intention of the code a bit more clear. The pattern (lazy-seq (when-let [s (seq coll)] ... is used in the implementation of* take-whil

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Andreas Kostler
Hi Stefan, I am overwhelmed by the 'freedom of choice' Clojure gives you, too. In that respect it's more like ruby than python. Nevertheless, I think if you can come up with an algorithm using the built in functions over sequences like map, reduce, filter, etc. you should do so. Either way, it

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Andreas Kostler
I can't answer that Ken, I guess I wasn't thinking of vec when I wrote it :) On 03/04/2011, at 5:17 PM, Ken Wesson wrote: > On Sun, Apr 3, 2011 at 1:04 AM, Andreas Kostler > wrote: >> (map (fn [x y] [x y]) coll (rest coll)) > > What's your reason for using (fn [x y] [x y])

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Stefan Rohlfing
@ Ken, Andreas Thank you for your nice implementations! As far as I can see, there are two main methods of comparing adjacent items of a list: 1) Take the first item of a coll. Compare the remaining items with an offset of 1: (map f coll (rest coll)) ;; apply some sort of filter 2) Take the f

Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Ken Wesson
On Sun, Apr 3, 2011 at 1:04 AM, Andreas Kostler wrote: >                       (map (fn [x y] [x y]) coll (rest coll)) What's your reason for using (fn [x y] [x y]) here instead of just vector? Is it more efficient because it isn't variable-arity? -- You received this message because you are su