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
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
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
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
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
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
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
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
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
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.
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
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
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
>
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
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:
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
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
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])
@ 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
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
33 matches
Mail list logo