Re: Users-prolog Digest, Vol 58, Issue 1

Duncan Patton a Campbell <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization 240am ltd.
Message-ID <[email protected]>
On Thu, 10 Jan 2008 12:00:34 -0500
[email protected] wrote:

> Send Users-prolog mailing list submissions to
> 	[email protected]
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.gnu.org/mailman/listinfo/users-prolog
> or, via email, send a message with subject or body 'help' to
> 	[email protected]
> 
> You can reach the person managing the list at
> 	[email protected]
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Users-prolog digest..."
> 
> 
> Today's Topics:
> 
>    1. help with proglod sort method (chasingamy)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Wed, 9 Jan 2008 00:41:25 -0800 (PST)
> From: chasingamy <[email protected]>
> Subject: help with proglod sort method
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=us-ascii
> 
> 
> Can somebody help me with this:
> 
> I have a number of paths that represent a a maze eg:
> 
> path(start, wall1).
> path(start, wall2).
> 
> this means from start you can go to wall1 or wall2 each wall also has a
> sound level attched to it eg:
> 
> sound(start,1).
> sound(wall1,2).
> 
> the higher the number the close to the exit you are. My problem is i am
> trying to write prolog that will do a breadthfirst search to find the exit,
> I have this working (i think!) but i need to write a method that will sort
> the path in order of sound so in my search when i do sortPath(Paths,
> Results) it will go through and sort it for me.
> 
> Any help at all would be excellent!

I'm not sure if this will help.  It is a sort that 
lets you sort on internal elements in a list.  If
you select to sort on "X" it will use that element
from each list to do the sorting on. 


%sorton(2,[[3,1,2],[2,2,2],[1,2,3]],X).
sorton(Ix,Lin,Lout):-!,
        sroti(Ix,Lin,NLS),
        sort(NLS),
        desroti(NLS,Lout).
desroti([],[]):-!.
desroti([[_,O]|NLS],[O|LOUT]):-!,
        desroti(NLS,LOUT).
sroti(_,[],[]):-!.
sroti(Ix,[In|Lin],[[InX,In]|Lout]):-
        nth(Ix,In,InX),!,
        sroti(Ix,Lin,Lout).
sroti(Ix,[In|Lin],[[0,In]|Lout]):-!,
        sroti(Ix,Lin,Lout).

Dhu


> -- 
> View this message in context: http://www.nabble.com/help-with-proglod-sort-method-tp14707350p14707350.html
> Sent from the Gnu - Prolog - Users mailing list archive at Nabble.com.
> 
> 
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> Users-prolog mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/users-prolog
> 
> 
> End of Users-prolog Digest, Vol 58, Issue 1
> *******************************************
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.