POV-Ray : Newsgroups : povray.general : Suggestion: array functions : Re: Suggestion: array functions Server Time
8 Aug 2024 12:22:44 EDT (-0400)
  Re: Suggestion: array functions  
From: Chris Huff
Date: 15 Feb 2001 06:31:55
Message: <chrishuff-5CAF2B.06315915022001@news.povray.org>
In article <uuhf8tot4cqub4e7vaj2r3r1r602q373cq@4ax.com>, Peter Popov 
<pet### [at] vipbg> wrote:

> pop 	Removes the last element of an array, and returns its value
> push 	Adds one or more elements to the end of an array
> reverse Reverses the direction of an array.
> sort 	Sorts an array in place
> shift 	Removes the first element from an array and returns its value
> unshift	Adds one or more elements to the beginning of an array
> slice 	Extracts a section of an array and returns it as a new array
> splice 	Adds and/or removes elements from an array

Don't forget copy and insert (maybe splice will do insert, and slice 
specifying the whole array would do copy, so maybe you didn't forget 
them...but maybe they should be included just for completeness).

These would be very useful, especially in things like particle 
simulations. Another idea: a for_all() function that takes an array and 
macro as parameters, and performs the macro on each defined item in the 
array.

#declare MyArray = array ...

#macro Update(Item, Array, Index)
    // the first three parameters of the macro would be the current
    // item, the array, and the index value.
    // Macros with 1 or 2 parameters should also be allowed.
#end

#macro Update2(Item, Array, Index, Time, Iterations)
    // Macros with more parameters would have them specified in the
    // for_all() call, and the same values would be used for all calls.
#end

for_all(MyArray, Update, MyClock, 25)

I have no idea how to do this, but it would probably be useful...and you 
could probably do most of it with a macro, but it wouldn't be as fast.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.