Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Nondeterministic algorithms, flexops, and stuff
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Piers Cawley  
View profile  
 More options Oct 30 2002, 9:48 am
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Wed, 30 Oct 2002 14:25:02 +0000
Local: Wed, Oct 30 2002 9:25 am
Subject: Nondeterministic algorithms, flexops, and stuff
Given an acyclic graph of nodes, where a node has a method C<kids>,
returning a list of all the nodes it points to, is it the case that
the following code:

  sub descent($src, $dst) {
    when $src == $dst  { return $dst }
    when !$src.kids    { die }
    otherwise {
      return ( $src, descent(any($src.kids), $dst))
    }
  }

will return a list of nodes making up a path between the nodes $src
and $dest? Or do I need to replace C<any> and C<die> with an
appropriate implementation of C<choose> and C<fail>?

It'd be really cool if superpositions had this kind of backtracking
behaviour, but I'm *so* not going to be surprised if it doesn't...

--
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Scott Duff  
View profile  
 More options Oct 30 2002, 11:48 am
Newsgroups: perl.perl6.language
From: d...@cbi.tamucc.edu (Jonathan Scott Duff)
Date: Wed, 30 Oct 2002 09:56:41 -0600
Local: Wed, Oct 30 2002 10:56 am
Subject: Re: Nondeterministic algorithms, flexops, and stuff

Hey, that's neat. Although it looks like it returns the $src when there
isn't a path. You probably want it to return undef or something.

Perhaps where you have "die" there should be something like
$src.collapse or maybe just "return undef".

-Scott
--
Jonathan Scott Duff
d...@cbi.tamucc.edu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piers Cawley  
View profile  
 More options Oct 30 2002, 11:48 am
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Wed, 30 Oct 2002 16:03:55 +0000
Local: Wed, Oct 30 2002 11:03 am
Subject: Re: Nondeterministic algorithms, flexops, and stuff
Jonathan Scott Duff <d...@cbi.tamucc.edu> writes:

Nah, it'll die when there isn't a path.

> Perhaps where you have "die" there should be something like
> $src.collapse or maybe just "return undef".

Well, traditionally you have 'fail' there, wants to be some kind of
exception, but I'm not entirely sure of what the semantics should
be.

You'd do C<pick(descent($src, $dst))> to get a path though, hopefully
it'd be resolved lazily. If not, the fact that we have continuations
means that it should be possible to implement a Grahamesque
'choose/fail' pair of funcs, but it'd be so much neater to do it with
superpositions...

--
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Scott Duff  
View profile  
 More options Oct 30 2002, 11:48 am
Newsgroups: perl.perl6.language
From: d...@cbi.tamucc.edu (Jonathan Scott Duff)
Date: Wed, 30 Oct 2002 10:45:00 -0600
Subject: Re: Nondeterministic algorithms, flexops, and stuff

On Wed, Oct 30, 2002 at 04:03:55PM +0000, Piers Cawley wrote:
> Jonathan Scott Duff <d...@cbi.tamucc.edu> writes:
> > Hey, that's neat. Although it looks like it returns the $src when there
> > isn't a path. You probably want it to return undef or something.

> Nah, it'll die when there isn't a path.

duh!  Of course.  I was too busy thinking about the recursion.

> > Perhaps where you have "die" there should be something like
> > $src.collapse or maybe just "return undef".

> Well, traditionally you have 'fail' there, wants to be some kind of
> exception, but I'm not entirely sure of what the semantics should
> be.

In my very-non-exceptional programming, I'd want undef if there wasn't
a path.   So, I guess your code is just fine but needs a CATCH block
in there.  The superposition collapses when it finds a path or finds
that there is no path, no backtracking would be required.

-Scott
--
Jonathan Scott Duff
d...@cbi.tamucc.edu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Hastings  
View profile  
 More options Oct 30 2002, 12:48 pm
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Wed, 30 Oct 2002 09:37:30 -0800 (PST)
Local: Wed, Oct 30 2002 12:37 pm
Subject: Re: Nondeterministic algorithms, flexops, and stuff
Way outside the stuff I "get", Larry mentioned something about a
"transactional model" for flexen.

I keep wanting that to play somewhere in there, but I can't get my
brain around how it should work. Essentially, I keep degenerating into
Prolog. Since I *REALLY* don't wish to change all my perl scripts into
makefiles, that's obviously not the way to go... >:-(

But the idea that the system will constrain prior flexen based on new
data makes me wonder how to provide the new data.

I have this little dental-drill in the back of my head telling me that
your recursion/die (or fail) could be replaced by something like &= and
a while loop, but I can't make it work. Am I barking up the wrong tree?

IOW:
-------------
my $cur = $src;
my @path;
do
{
  push @path, $cur;
  return undef
    unless $cur = any $cur.kids;

}

while ($cur != $dst);

# But now there's all these flexen
# in @path that haven't collapsed, because
# their intermediate values were valid flexen.

my @result;
do
{
  unshift @result, $cur;
  $cur = pop @path;
  $cur &= any $cur.kids == $last;

} while ($cur);  

----------------

But that's hideous. Putting the recursion back in:

sub descend($src, $dst)
{
  return $dst if $src == $dst;
  return undef unless $src.kids;
  my @result = descend(any $src.kids, $dst);

  # Trying to tie up the flexen. Am I insane?

  $src &= any $src.kids == $result[0];
  unshift @result, $src;
  return @result;

}

=Austin

--- Jonathan Scott Duff <d...@cbi.tamucc.edu> wrote:

__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piers Cawley  
View profile  
 More options Oct 30 2002, 1:48 pm
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Wed, 30 Oct 2002 18:45:49 +0000
Local: Wed, Oct 30 2002 1:45 pm
Subject: Re: Nondeterministic algorithms, flexops, and stuff
Jonathan Scott Duff <d...@cbi.tamucc.edu> writes:

Tell you what, here's a non flexop translation of the Lisp code I
borrowed my example from. Assume for a moment that Perl has
call_with_current_continuation (it should have *something* like it...)

  my @paths;

  sub choose(*@choices) {
    fail unless @choices;
    call_with_current_continuation -> $cc {
      push @paths, sub { $cc( choose @choices[1...@choices.last] ) };
    }
  }

  sub fail {
    return "Exhausted Choices" but false unless @paths;
    my $p1 = pop @choices;
    $p1.();
  }

  sub descent($src, $dst) {
    when $src == $dst { return $dst }
    when !$src.kids   { fail }
    otherwise { return $src, descent(choose($src.kids), $dst) }
  }

Actually, doing things this way allows one to control whether one
searchs depth or breadth first. For breadth first, just change the
'push' in choose to an unshift...

--
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »