[Haskell-cafe] In-place modification

Hugh Perkins hughperkins at gmail.com
Sun Jul 15 14:04:16 EDT 2007


On 7/15/07, Hugh Perkins <hughperkins at gmail.com> wrote:
>
> On 7/15/07, Hugh Perkins <hughperkins at gmail.com> wrote:
> >
> > I'd have a go in C# at 'chameneos', a concurrency
> > > benchmark,
> > >
> > >      http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneos&lang=all
> > >
> > >
> >
> >
> Errr this is kindof a strange problem, the answer is always N * 2?
>
> And there we see why I dislike shootout ;-)
>
>
By the way, sortof felt guilty for not really creating imaginary Chameneos,
and there's also the race condition to think about.

Race condition
===========

(or: why is it N * 2)

There is an insane race condition in the question, which really renders the
question rather uncool, but let's accept for now that it's ok to have insane
race conditions in our programs.  There are two possibilities:

1. The insane race condition means that each test condition produces a
different output, and the question is entirely invalid
2. The race condition has no affect on the output

If 1 is true, the question is entirely invalid.  We're going to assume that
the question is valid, which means the race condition has no affect on the
result.

That means that we can imagine the chaemeneos meeting in any order we like.

So we send c1 then c2.  That's one meeting, and each chameneos has met other
other chameneos.

We iterate N times, so C1 and c2 both met another chameneos N times, giving
a total of N * 2.

The colors are entirely irrelevant, and do not have any affect on the
meetings, because they do not affect whether meetings take place or not.

Imaginary Chameneos
================

The question asks us to imagine N chameneos of different colors meeting.
Chameneos do not really exist, they're an imaginary creation.  So we have to
imagine N imaginary chameneos meeting imaginarily.

Rest assured, as I pressed the "Enter" key I did duly imagine the 100
chameneos in many colors all meeting and changing colors and becoming faded.

Oh, you want the computer to imagine the imaginary chameneos meeting and
changing colors?  Well now, a computer doesnt really imagine anything, we
ascribe meaning to arbitrary symbols in our code.

So, just to put your mind at rest,  the function "Chameneos.Go( int N )" in
my code represents N chameneos in many colors meeting and changing colors,
so to the extent that a computer can imagine things, the computer really did
imagine imaginary chameneos imaginarily meeting :-D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070715/1715a49b/attachment.htm


More information about the Haskell-Cafe mailing list