Re: How to reset a counter

2010-05-30 Thread Moritz Ulrich
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 wrote: > > This is precisely what 'for' is for in clojure. > > For example: > > (for [x (range 10) y (range 10)] [x y]) > > ... produces a seque

Re: How to reset a counter

2010-05-30 Thread James Reeves
On 30 May 2010 12:42, Michael Wood wrote: > Well, what's wrong with this: > > for (k = 0; k < 256; ++k) >  writeBuffer(k % 16, k / 16, value[k]); > > :) I was about to say the same thing. Clojure can be more concise than most other languages, but in this case, all one needs is a simple loop, modu

Re: How to reset a counter

2010-05-30 Thread John Cromartie
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

Re: How to reset a counter

2010-05-30 Thread Michael Wood
On 30 May 2010 12:39, WoodHacker wrote: > > > On May 29, 9:44 am, James Reeves wrote: >> On 29 May 2010 14:19, WoodHacker wrote: >> >> > 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

Re: How to reset a counter

2010-05-30 Thread WoodHacker
On May 29, 9:44 am, James Reeves wrote: > On 29 May 2010 14:19, WoodHacker wrote: > > > 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,

Re: How to reset a counter

2010-05-29 Thread Adrian Cuthbertson
Also have a look at Christophe's excellent "Taming multidim Arrays"... http://clj-me.cgrand.net/2009/10/15/multidim-arrays/ -Rgds, Adrian -- 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 N

Re: How to reset a counter

2010-05-29 Thread Meikel Brandmeyer
Hi, here an example using clojure sequence library. (require 'clojure.contrib.seq-utils) (doseq [[y vs] (indexed (partition 256 value)) [x v] (indexed vs)] (write-buffer x y v)) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: How to reset a counter

2010-05-29 Thread James Reeves
On 29 May 2010 14:19, WoodHacker wrote: > 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 matri

How to reset a counter

2010-05-29 Thread WoodHacker
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 t