On Tue, Nov 25, 2008 at 9:40 AM, Arie Groeneveld <[EMAIL PROTECTED]> wrote:
> After reading some literature about subject I can only conclude
> solutions like the Haskell example are not really what Amb should do. It
> just produces all possibilities at once.
>
> Check out ref. http://tinyurl.com/6g9uzc
> See also some discussion in the RC article:
> http://www.rosettacode.org/wiki/Talk:Amb

I would wait until someone can come up with a real description
for amb.

Right now, it's someone showing off a bit of scheme trickery.
But it's more a solution looking for a problem than anything
useful.  The lack of comprehensibility of the english
description is a reflection of this issue.

In other words:
   amb=:2 :'{.(#~u&>),{n'

Of course, this is not particularly efficient, and also may
not be doing the right thing if none of the sequences are
acceptable.

The latter issue -- what happens when none of the cases
are acceptable -- is a part of the slipshod character of
the specification.  But to address that issue they would
either have to restate the problem so that it fits any
language or they would have to exclude some kinds of
implementations that I think they are trying to allow for.

The former issue -- that of performance -- is less important.
This is the old "pre-optimization is the root of all evils
in programming".  In other words: do not optimize until you
are solving the right problem, otherwise you just wind up with
a really fast way of arriving at the wrong answer.

Also, think about it: what if you want more than one of the
potential valid results?  The current spec specifically has
no provisions for this case.  And your first inclination on
seeing an implementation which could address this flaw (the
Haskell example) was to treat it as invalid.

So, anyways, I think that that "amb" example is just bad
programming, and I would avoid getting involved in it if
I were you.  (But, of course, I am not.)

(P.S., if this were something worthwhile, Roger could add
special code to the interpreter to improve its performance
for this algorithm.)

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to