It's also worth to mention that the produced seq is lazy, so you can
work on big images without memory issues.

On Saturday, May 29, 2010, John Cromartie <jcromar...@gmail.com> wrote:
>
> This is precisely what 'for' is for in clojure.
>
> For example:
>
> (for [x (range 10) y (range 10)] [x y])
>
> ... produces a sequence of the coordinates in a 10x10 grid. You can
> then consume the sequence for whatever purpose. The position of each
> matrix coord in the seq produced would match up with the position of
> the data in your array.
>
> On May 29, 9:19 am, WoodHacker <ramsa...@comcast.net> wrote:
>> I've been working with Lisp and Scheme for the past few years and have
>> migrated to Clojure because of the JVM.   I think I get functional
>> programming, but one problem is giving me fits.
>>
>> I'm working on  a simple imaging problem.   I want to copy an array of
>> pixels to an image buffer.   That means that I have to deal both with
>> an array and a matrix (x and y).   As I go along my array, each time x
>> reaches the end of a line in the matrix I have to set it back to zero
>> and increment y.
>>
>> I can find no simple way to do this without getting a compile error.
>> Can someone show me how to do this?
>>
>> Example in pseudo code:
>>
>>     x = 0
>>     y = 0
>>
>>     for  (k = 0; k < 256; ++k)
>>        if (= x 16) {
>>           x = 0
>>          (inc y)
>>       }
>>       else
>>          (inc x)
>>
>>      writeBuffer (x, y, value[k])
>>
>> Bill
>
> --
> 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

-- 
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

Reply via email to