Trying to use lazy-seq for the first time, failing.

2009-06-27 Thread _hrrld

Hi,

I'm trying to use lazy-seq to implement a cool piece of functionality
I saw in the Factor programming language. Here is the documentation
for that functionality:
http://docs.factorcode.org/content/word-produce,sequences.html

I think a lazy version of Factor's "produce" word would be super-
powerful for some of the things I'm working on.

This is the first time I've tried to create my own lazy sequence, so
don't laugh.

Here is my attempt:
http://gist.github.com/136825

For some reason, the lazy sequence that is returned is always empty
(?) or at least seems that way.

Am I doing something silly? Or perhaps I've misunderstood lazy-seq's
operation.

Thanks in advance for any advice,
-Harold

--~--~-~--~~~---~--~~
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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Trying to use lazy-seq for the first time, failing.

2009-06-27 Thread _hrrld

On Jun 27, 9:48 am, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 27.06.2009 um 02:23 schrieb _hrrld:
>
> > Am I doing something silly? Or perhaps I've misunderstood lazy-seq's
> > operation.
>
> I think, it's the latter. Here my try on an explanation:
> (snip...)

I found your explanation cogent and helpful, thank you.

> And finally you can get something similar with Clojure sequence
> library. I think it's slightly different to your code, but maybe
> it also works for you.
>
> (defn slightly-different-produce
>    [pred generator value]
>    (take-while pred (iterate generator value)))

take-while iterate... This is great also.

Much appreciated,
-Harold
--~--~-~--~~~---~--~~
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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Trying to use lazy-seq for the first time, failing.

2009-06-29 Thread _hrrld

On Jun 29, 1:15 am, Emeka  wrote:
> Harold,
>
> Do you have any material on Factor? I won't going through it.

Emeka,

Many of these links are relevant:
http://www.google.com/search?q=factor+language

Regards,
-Harold
--~--~-~--~~~---~--~~
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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Newbish question. Does anyone have any example code for playing a wav sound file?

2009-07-27 Thread _hrrld

On Jul 27, 7:00 pm, Rayne  wrote:
> All I'm trying to do is play a simple .wav sound file once.
>
> I'll appreciate any examples!

I'm hesitant to even share this, since I consider myself a rank
Clojure and Java neophyte, but I think it is what you're asking for:
http://github.com/harold/clj-sound/tree/master

Specifically, have a look at sound-test.clj in that project.

It plays the wav file (on my machine at least), but I'd be very
surprised if it were anything like the way someone who knew what they
were doing would do it.

In any event,
-Harold
--~--~-~--~~~---~--~~
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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Processing elements in a lazy seq in parallel

2009-08-10 Thread _hrrld

On Aug 10, 12:18 pm, Tom Emerson  wrote:
> Hello Clojurians,
>
> file-seq gives me a convenient way to get a seq of all these files.
> What I would like to do is process elements in this sequence in
> parallel. My first thought was to process the seq with pmap, but this
> is suboptimal because I'm not interested in saving the return value of
> function called on each file.
>

Hi Tom,

I built something that does something similar to what you're
describing.

There's likely a better way to do what I've done, but you still may be
interested to see it:
http://github.com/harold/p4check/tree/master

It uses agents to achieve parallelism, and runs quite fast and soaks
the cpus in my multi-core machine nicely. It's much faster than the
previous single-threaded version was.

Hope that helps,
-Harold
--~--~-~--~~~---~--~~
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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---