POV-Ray : Newsgroups : povray.off-topic : A comparison : Re: A comparison Server Time
10 Oct 2024 17:21:43 EDT (-0400)
  Re: A comparison  
From: scott
Date: 19 Mar 2008 03:39:39
Message: <47e0d14b$1@news.povray.org>
>   To compute SUM(LIST):
>     1. Let TOTAL = 0.
>     2. Let POSITION = first node of LIST.
>     3. Let TOTAL = TOTAL + value at POSITION.
>     4. Let POSITION = next node after POSITION.
>     5. If POSITION is not the end of the list, go to step 3.
>
> And now, the Other Way:
>
>   1. If LIST is the empty list then SUM(LIST) is defined as 0.
>   2. Otherwise, SUM(LIST) is defined as the first element of LIST + 
> SUM(rest of LIST).
>
> Personally, several things strike me here.
>
> 1. The first version seems a very long and wordy way of explaining 
> something that (to a human) is actually quite simple.
>
> 2. The second version is very much shorter. (And simpler?)

You made it simpler, I can make the first one simpler too :-)

1. If LIST is not the empty list, then SUM(LIST) is defined as the result of 
adding up the value at each node of LIST

> 3. The second version looks like some kind of a riddle. Not a hard riddle, 
> but a somewhat baffling definition all the same.

And seems unnecessarily complex.  Why bother going through splitting lists 
and passing them to recursive functions, when all you really need to do is 
loop through all entries and add up the numbers?


Post a reply to this message

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