"Average of List of Numbers" by Abigail 
Author Message
 "Average of List of Numbers" by Abigail

The Museum of Modern Programming is proud to present its first work:

"Average of List of Numbers" by Abigail.

The Museum of Modern Programming: http://www.*-*-*.com/

--
Terrence Brannon
Carter's Compass:
 I know I'm on the right track when by deleting code I'm adding functionality.



Fri, 25 Jul 2003 06:52:03 GMT  
 "Average of List of Numbers" by Abigail

Quote:

> The Museum of Modern Programming is proud to present its first work:

> "Average of List of Numbers" by Abigail.

What is so striking elegant about that solution. Here some Common Lisp
stuff:

(setf list '(1 2 3 4 5 6 7 8 9 10))
(/ (apply #'+ list) (length list))

Regards
Friedrich



Fri, 25 Jul 2003 17:11:43 GMT  
 "Average of List of Numbers" by Abigail
print "5.5\n";

Which is what I would give a program like that for maintainability. :)
(Should I put on my flame proof pants now?)

Quote:

> The Museum of Modern Programming is proud to present its first work:

> "Average of List of Numbers" by Abigail.

> The Museum of Modern Programming: http://www.momp.org

> --
> Terrence Brannon
> Carter's Compass:
>  I know I'm on the right track when by deleting code I'm adding functionality.



Fri, 25 Jul 2003 18:30:14 GMT  
 "Average of List of Numbers" by Abigail


Quote:
> "Average of List of Numbers" by Abigail.

Proving a good programmer can write APL in any language.

--
 `-_-'   In hoc signo hack, Peter da Silva.
  'U`    "A well-rounded geek should be able to geek about anything."

         Disclaimer: WWFD?



Sat, 26 Jul 2003 00:47:16 GMT  
 "Average of List of Numbers" by Abigail


Quote:

>> The Museum of Modern Programming is proud to present its first work:

>> "Average of List of Numbers" by Abigail.

>What is so striking elegant about that solution.

I guess someone thinks that "elegant" means "clever, obscure, and
inefficient".

--

Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Sat, 26 Jul 2003 02:30:47 GMT  
 "Average of List of Numbers" by Abigail

Quote:
> The Museum of Modern Programming is proud to present its first work:
> "Average of List of Numbers" by Abigail.
> The Museum of Modern Programming: http://www.momp.org

on 5 February:

$ nslookup www.momp.org
Server:  dns1.motion.net
Address:  216.1.104.12

*** dns1.motion.net can't find www.momp.org: Non-existent host/domain

Chris
--
Christopher E. Stith

Product shown enlarged to make you think you're getting more.



Sat, 26 Jul 2003 05:13:40 GMT  
 "Average of List of Numbers" by Abigail
On Mon, 05 Feb 2001 21:13:40 -0000,

Quote:

>> The Museum of Modern Programming is proud to present its first work:

>> "Average of List of Numbers" by Abigail.

>> The Museum of Modern Programming: http://www.momp.org

> on 5 February:

> $ nslookup www.momp.org
> Server:  dns1.motion.net
> Address:  216.1.104.12

> *** dns1.motion.net can't find www.momp.org: Non-existent host/domain

$ nslookup
Default Server:  wula.comdyn.com.au
Address:  172.18.240.18

Quote:
> www.momp.org

Server:  wula.comdyn.com.au
Address:  172.18.240.18

Non-authoritative answer:
Name:    www.momp.org
Address:  209.132.1.73

Quote:
> server dns1.motion.net

Default Server:  dns1.motion.net
Address:  216.1.104.12

Quote:
> www.momp.org

Server:  dns1.motion.net
Address:  216.1.104.12

*** dns1.motion.net can't find www.momp.org: Query refused

Seems the problem is with your server.

Martien
--
Martien Verbruggen              |
Interactive Media Division      | In the fight between you and the
Commercial Dynamics Pty. Ltd.   | world, back the world - Franz Kafka
NSW, Australia                  |



Sat, 26 Jul 2003 08:41:23 GMT  
 "Average of List of Numbers" by Abigail

Quote:

>> The Museum of Modern Programming is proud to present its first work:
>> "Average of List of Numbers" by Abigail.
>> The Museum of Modern Programming: http://www.momp.org

[nameserver problem report snipped]

I have seen the page, and although I admit Abigail usually does
impress me (and does so to an extent with this example), I find it
hard to call the example "strikingly elegant".

Below is a threesome of ways to find averages in only a few
characters. It also includes a control. The first two are
written by me, and only need to have $avg preset to zero if
they are not the first assignment to it. The third is
Abigail's. Since the first does use more divisions, it does
build up more floating point imprescision and it shows this

lines that figure average is the control for how to very
obviously do this.

If you call elegance a lack of length, then mine share that.
If you call elegance speed and clarity, then the control
wins hands down. If you call elegance a somewhat unusual
use of a feature, mine share that. My less precise method
is even shorter, including the presetting of the variable.
Granted, my methods are a little clunkier before the eyes,
since they require multiple statements. Still, though, can
you afford a 92% slowdown from the obvious implementation?
Is that elegance? Perhaps it's elegant because it is only
one statement (which could be arguable on some level
since it uses both do and eval)?

Like I mentioned earlier, Abigail's knowledge of the language
impresses me, including in this example. I doubt, though, that
Abigail herself would call her example "strikingly elegant".
Impressive in how it's done, perhaps. Impressive in its length
or its speed, no.

#!/usr/bin/perl -w
use strict;

my $avg;

### less precise map()
### 11003.90 per second averaging 1..10
###     0.78 per second averaging 1..100_000

print $avg . "\n";

### more precise map()
### 17837.98 per second averaging 1..10
###     1.47 per second averaging 1..100_000

print $avg . "\n";

### Abigail's do()
###  1929.00 per second averaging 1..10
###     0.31 per second averaging 1..100_000

print $avg . "\n";

### foreach() as control
### 24908.89 per second averaging 1..10
###     4.67 per second averaging 1..100_000

print $avg . "\n";

Chris
--
Christopher E. Stith

Parking for people we like only. All other vehicles will be vandalized.



Sat, 26 Jul 2003 08:48:15 GMT  
 "Average of List of Numbers" by Abigail


Quote:
> *** dns1.motion.net can't find www.momp.org: Non-existent host/domain

Your DNS server - or the one your computer is configured to "talk" to -
haven't been updated with this domain name yet.

Try using http://lnc.usc.edu/~brannon/domains/momp.org/ instead, but
change back to www.momp.org when you know that it's working alright.

Disclaimer;  I have nothing to do with www.momp.org, but I like the
site already. :)

--



Sat, 26 Jul 2003 08:55:48 GMT  
 "Average of List of Numbers" by Abigail

Quote:

> Like I mentioned earlier, Abigail's knowledge of the language
> impresses me, including in this example. I doubt, though, that
> Abigail herself would call her example "strikingly elegant".
> Impressive in how it's done, perhaps. Impressive in its length
> or its speed, no.

From the mentioned page
|Shown here is a strikingly elegant way to calculate the average of an array of numbers.
|>Artiste: Abigail
|Medium: Perl

Regards
Friedrich



Sat, 26 Jul 2003 15:26:49 GMT  
 "Average of List of Numbers" by Abigail
On Wed, 7 Feb 2001 04:58:17 +0000 (UTC), Gregory Neil Bastow

Quote:


>: In the context of programming, I've always thought elegance had to do
>: with doing something in a way that is either conscise and fast or simple
>: but not necessarily obvious.

>Not sure what you mean about "obviousness" with respect to elegance.
>I think it should be fairly easy to see what it does and how it works, but
>usually taking a non-obvious step to come up with it in the first place.
>-Greg

Elegance in all matters, whether mathematical, musical, visual or
anything else is simply this(pun intended<grin>):

The shortest line between two points!

HERE:route:OBJECTIVE

Monte
.
.
.
.
.
.
.
.
.
.



Sun, 27 Jul 2003 17:47:16 GMT  
 "Average of List of Numbers" by Abigail
On Wed, 7 Feb 2001 04:58:17 +0000 (UTC), Gregory Neil Bastow

Quote:


>: In the context of programming, I've always thought elegance had to do
>: with doing something in a way that is either conscise and fast or simple
>: but not necessarily obvious.

>Not sure what you mean about "obviousness" with respect to elegance.
>I think it should be fairly easy to see what it does and how it works, but
>usually taking a non-obvious step to come up with it in the first place.
>-Greg

Elegance in all matters, whether mathematical, musical, visual or
anything else is simply this(pun intended<grin>):

The shortest line between two points!

HERE:route:OBJECTIVE

Monte



Sun, 27 Jul 2003 17:46:17 GMT  
 "Average of List of Numbers" by Abigail
On Wed, 7 Feb 2001 04:58:17 +0000 (UTC), Gregory Neil Bastow

Quote:


>: In the context of programming, I've always thought elegance had to do
>: with doing something in a way that is either conscise and fast or simple
>: but not necessarily obvious.

>Not sure what you mean about "obviousness" with respect to elegance.
>I think it should be fairly easy to see what it does and how it works, but
>usually taking a non-obvious step to come up with it in the first place.
>-Greg

Elegance in all matters, whether mathematical, musical, visual or
anything else is simply this(pun intended<grin>):

The shortest line between two points!

HERE:route:OBJECTIVE

Monte



Sun, 27 Jul 2003 17:39:12 GMT  
 "Average of List of Numbers" by Abigail

Quote:
> On Wed, 7 Feb 2001 04:58:17 +0000 (UTC), Gregory Neil Bastow


>>: In the context of programming, I've always thought elegance had to do
>>: with doing something in a way that is either conscise and fast or simple
>>: but not necessarily obvious.

>>Not sure what you mean about "obviousness" with respect to elegance.
>>I think it should be fairly easy to see what it does and how it works, but
>>usually taking a non-obvious step to come up with it in the first place.
>>-Greg

Greg,

Like I said, "simple but not necessarily obvious". I agree to be
considered elegant something should be clearly understood when it
is read but not something that would be the most obvious
implementation path before seeing it. Good examples (in my
mind at least) would be the Schwartzian transform, quicksort, and
the Boyer-Moore string search.

Quote:
> Elegance in all matters, whether mathematical, musical, visual or
> anything else is simply this(pun intended<grin>):
> The shortest line between two points!
> HERE:route:OBJECTIVE

Monte,

I suppose posting the same message three times is the shortest
line to making your point? ;)

And what does shortest line mean in programming? The quickest
initial implementation? The fastest run time? The fastest
maintenance turnaround? The most concise code? The fewest actual
program statements, regardless the length of each? The code that
becomes the fewest machine-level opcodes? The least use of memory?
There are many lines that intersect when programming. Which one
should be the shortest? If it's a combination of all the lengths,
how do you weight each one?

Chris
--
Christopher E. Stith

If they can get you asking the wrong questions, they don't
have to worry about the answers.
  -- Thomas Pynchon, Gravity's Rainbow



Mon, 28 Jul 2003 00:10:37 GMT  
 "Average of List of Numbers" by Abigail
On Wed, 07 Feb 2001 16:10:37 -0000, Chris Stith >

Quote:
>>Monte wrote--> Elegance in all matters, whether mathematical, musical, visual or
>> anything else is simply this(pun intended<grin>):

>> The shortest line between two points!

>> HERE:route:OBJECTIVE

>>Monte,

>I suppose posting the same message three times is the shortest
>line to making your point? ;)

I have no idea why or how that got repeated.

Quote:

>And what does shortest line mean in programming? The quickest
>initial implementation? The fastest run time? The fastest
>maintenance turnaround? The most concise code? The fewest actual
>program statements, regardless the length of each? The code that
>becomes the fewest machine-level opcodes? The least use of memory?
>There are many lines that intersect when programming. Which one
>should be the shortest? If it's a combination of all the lengths,
>how do you weight each one?

>Chris

Beauty is in the eye of the beholder.  Elegance being linguistically
related to beauty holds a similar definition.   You are quibbling.
Just as in art, when Perl or any other program appears 'elegant' it
is.  If it does not appear so, then it isn't.  Remember, beautiful
ladies come in many different packages.  Why do you think Larry gave
this language a womens name?<grin>

Secondly most of the factors you list are inter-related and so when
one is optimized the others follow.  Optimizing one does not optimize
the others necessarily, but if you program enough years you will know
that the others become weighted automagically as a result of
optimizing the prime factor that tickles your fancy and suits the
projects goals.



Mon, 28 Jul 2003 05:13:49 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Calculating Average Values using "Mean" vi

2. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

3. BEGIN{want[]={"s1o", "s2o", "s2q", "s3q"}

4. Parsing ""D""?

5. "Fifth", "Forth", zai nar?

6. "running" numbers

7. (string->number "#e1.43#")

8. Ruby "finalize", "__del__"

9. beginners "let"/"random" question

10. maximum number of "always" statement

11. Counting Number of "Backtrak's"

12. mistake in "Factors of a number"

 

 
Powered by phpBB® Forum Software