[Tutor] Can you modify every nth item in a list with a single assignment?

Jeff Shannon jeff@ccvcorp.com
Fri Jun 13 14:07:01 2003


R. Alan Monroe wrote:

>>What is your goal here?
>>    
>>
>
>I'd like to, for instance, draw a column of pixels in a 2d video
>buffer that's implemented as a 1d array.
>  
>


Any particularly compelling reason to implement this as a 1d array? 
 (The fact that it's normally done that way in C is, IMHO, distinctly 
*not* a compelling reason.)  It seems to me that you're trying to 
implement matrix mathematics in a 1d list.  You'll almost certainly have 
better luck if you use the right data structure for the job.  If you're 
manipulating a video buffer, I'd strongly recommend either using a 
graphics-oriented library (such as wxOGL or PyGame) or, if you must 
manage pixels individually,  check out Numeric which has many fast 
array- and matrix-handling routines.  

Jeff Shannon
Technician/Programmer
Credit International