🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #556

Re: general PROLOG questions

#556
From: Lee Naish
Date: Fri, 08 Dec 1989 07:51
42 lines
2093 bytes
In article <5631@uhccux.uhcc.hawaii.edu> cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65) writes:
>        1)   I need to know how to write a set of PROLOG rules
>             that represent the rules of some organizational   
>             system such as: the conditions for passing a 
>             course in college
pass_condition([68,111,32,116,104,101,32,112,114,111,106,
		101,99,116,32,121,111,117,114,115,101,108,
		102,33]).

>
>       2)    Using a definitions of the listsize predicate for   
>             guidence, a definition for a rule that will return
>             the nth element of a given list. For example:    
>             nth([a,short,list],2,Nth) should return Nth = short.
listsize([_, _, _, _ | _], 'BIG') :- !.
listsize(_, small).

Hence it is easy to extend this to nth, at least for small lists.

>       3)    To write a set of PROLOG rules to determine if a given
>             list of integers is in ascending order.
ascending(L) :- sort(L, S),
	( L = S ->
		write(yes)
	; listsize(L, S1),listsize(S, S1) ->
		write(no)
	;
		write(maybe)
	).

>       4)    In the following  program:
Unfortunately there were several syntax errors on the system I ran it
on, so I am unable to help you in detail.  However, try reading some of
Dijkstra's work.  I think he develops a shortest path algorithm quite
nicely.

>         link (A,B,D) :-
               ^
>        and with the of what is the route from A to B and the total distance?
                      ^
>             route 1(S,F,[S],R,D).
                     ^
Technical Details
Message-ID: <2898@munnari.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!lee
References: <5631@uhccux.uhcc.hawaii.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!lee
From: lee@munnari.oz.au (Lee Naish)
Newsgroups: comp.lang.prolog
Subject: Re: general PROLOG questions
Keywords: new user..
Message-ID: <2898@munnari.oz.au>
Date: 8 Dec 89 07:51:26 GMT
References: <5631@uhccux.uhcc.hawaii.edu>
Sender: news@cs.mu.oz.au
Reply-To: lee@munmurra.UUCP (Lee Naish)
Organization: Comp Sci, University of Melbourne
Lines: 42