POV-Ray : Newsgroups : povray.general : Suggestion: array functions Server Time
8 Aug 2024 10:19:22 EDT (-0400)
  Suggestion: array functions (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Geoff Wedig
Subject: Re: Suggestion: array functions
Date: 12 Feb 2001 12:45:11
Message: <3a882126@news.povray.org>
Peter Popov <pet### [at] vipbg> wrote:

> Arrays are a very useful addition to POV but there are some
> restrictions imposed by the current implementation. Therefore I
> suggest that a set of functions to operate with arrays be added to POV
> (well, to some unofficial version at the moment, since the feature
> list of 3.5 is locked):

> <list snipped>

> What do you people (esp. the program-oriented folk) think about these?
> Would they be useful? If so, would any kind soul care to patch them
> in? :))

This would be *heaven*.  I have been working with arrays a lot as of late,
and it would be really nice to be able to do these sorts of things.  For
example, I've been doing clipping algorithms (clipping a shape defined by 2d
points to some other shape defined by 2d points), and it'd be really nice to
be able to splice sections together, remove invalid points, etc.  To do this
now, it is necessary to first count how many points will be in the new
array, then contruct it, then transfer it to the old array.  Ugly code, and
slow too.

So, are you volunteering to add this? ;)

Geoff


Post a reply to this message

From: Peter Popov
Subject: Re: Suggestion: array functions
Date: 13 Feb 2001 16:23:22
Message: <rd9j8tsd9hcidq7fr6eehc6ueniv5tfq8k@4ax.com>
On 12 Feb 2001 12:45:11 -0500, Geoff Wedig
<wed### [at] darwinepbicwruedu> wrote:

>So, are you volunteering to add this? ;)

Actually, no <blush>. I am quite busy at the Uni and when I eventually
have to resurrect whatever programming skills I might have left, I
will need all the time I have to work on my bachelor's project. Sorry.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Warp
Subject: Re: Suggestion: array functions
Date: 14 Feb 2001 05:27:53
Message: <3a8a5da9@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
: Except that STL isn't portable enough yet for even the supported platforms.

  Which platform/compiler doesn't support basic STL?

  (I understand that perhaps not every compiler supports the newest features
of the STL, such as stream iterators and string iterators, but I think that
most support the basic data containers such as vector and deque.)

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Warp
Subject: Re: Suggestion: array functions
Date: 14 Feb 2001 05:30:59
Message: <3a8a5e63@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
: This one might be a bit of an issue.  Not everything that can be put in 
: an array can be sorted.  In fact, most things that can be put in an array
: are unsortable.

  Then we have to be able to add a less-than-comparison operator to any
declarable object... :)
  Of course for that operator to be useful it should be able to extract
data from the object itself (such as its coordinates or whatever).

  By the way, sorting an array of numerical values can be done easy and
fast with a proper macro. Several array sorting macros (including mine) have
been posted here in other threads.

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Geoff Wedig
Subject: Re: Suggestion: array functions
Date: 14 Feb 2001 07:54:47
Message: <3a8a8017@news.povray.org>
Peter Popov <pet### [at] vipbg> wrote:

> On 12 Feb 2001 12:45:11 -0500, Geoff Wedig
> <wed### [at] darwinepbicwruedu> wrote:

>>So, are you volunteering to add this? ;)

> Actually, no <blush>. I am quite busy at the Uni and when I eventually
> have to resurrect whatever programming skills I might have left, I
> will need all the time I have to work on my bachelor's project. Sorry.

Drat. ;)

Geoff


Post a reply to this message

From: Alessandro Coppo
Subject: Re: Suggestion: array functions
Date: 15 Feb 2001 02:56:41
Message: <3a8b8bb9@news.povray.org>
If you have portability troubles, see www.stlport.org. There are lots of
supported compilers.

Apropos STL problems: there are brain-damaged compilers (any reference to
VisualC++ is purely intentional) which cannot handle partial template
specializations but, with enough #ifdefs...

Bye!!!!

Alessandro Coppo
a.c### [at] iolit


Post a reply to this message

From: Chris Huff
Subject: Re: Suggestion: array functions
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

From: Peter Popov
Subject: Re: Suggestion: array functions
Date: 16 Feb 2001 16:08:18
Message: <rggp8t019366bfd5tqif0rami2l5pk9ihm@4ax.com>
On Thu, 15 Feb 2001 06:31:59 -0500, Chris Huff <chr### [at] maccom>
wrote:

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

Similar to ForEach(x) in Pascal. IIRC (I haven't touched Pascal in
like eight years) it worked like this:

foreach(something) do
begin
  ...
  ...
  ...
end;

I would also like to see an equivalent of the 'with' but that would
imply an OO concept and I don't think it's time for that yet (I hear
booing already)


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Chris Huff
Subject: Re: Suggestion: array functions
Date: 22 Feb 2001 11:58:06
Message: <chrishuff-9385F4.11571122022001@news.povray.org>
In article <rggp8t019366bfd5tqif0rami2l5pk9ihm@4ax.com>, Peter Popov 
<pet### [at] vipbg> wrote:

> I would also like to see an equivalent of the 'with'

What do you mean? I don't remember using "with" in Pascal, but my only 
experience with Pascal was a class a couple years ago.


> but that would imply an OO concept and I don't think it's time for 
> that yet (I hear booing already)

It's too bad people have knee-jerk reactions to this kind of thing...POV 
manipulates objects, so some basic OO concepts would fit right in. It 
already has a kind of inheritance...(copies of objects inherit from the 
original variable, and can override some attributes, like texture and 
position. I think this is called "prototype-based inheritance", and it 
seems to be a perfect fit for POV.)

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

From: Ron Parker
Subject: Re: Suggestion: array functions
Date: 22 Feb 2001 12:14:06
Message: <slrn99ai70.qdv.ron.parker@fwi.com>
On Thu, 22 Feb 2001 11:57:11 -0500, Chris Huff wrote:
>In article <rggp8t019366bfd5tqif0rami2l5pk9ihm@4ax.com>, Peter Popov 
><pet### [at] vipbg> wrote:
>
>> I would also like to see an equivalent of the 'with'
>
>What do you mean? I don't remember using "with" in Pascal, but my only 
>experience with Pascal was a class a couple years ago.

If C had an equivalent, you could do something like this:

struct foo {
  int bar;
  int baz;
} quux, zort;

with (quux) {
  bar = 0;
  baz = 2;
}

Essentially, it saves you from having to type "quux." a bunch of times.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

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