🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1069

Re: Simple Prolog Question

#1069
From: Richard A. O'Keefe
Date: Mon, 13 Aug 1990 07:07
31 lines
1523 bytes
> Richard A. O'Keefe (ok@goanna.cs.rmit.oz.au) writes:
> > 	remove_leading_blanks([32|T], R) :- !,
> > 		remove_leading_blanks(T, R).
> > 	remove_leading_blanks(T, R).
			      ^^^^  mistake, should be R, R
In article <24120@megaron.cs.arizona.edu>,
debray@cs.arizona.edu (Saumya K. Debray) writes:

> I think I would prefer the following ("look, Ma, no choice points"):
> 
> 	remove_leading_blanks([], []).
> 	remove_leading_blanks([H|T], L) :-
> 		(   H =:= " " ->
> 	            remove_leading_blanks(T, L)
>		;/* H =\= " " */
>		    L = [H|T]
>		).

I'd prefer that too.  Indeed, Debray's SB-Prolog will let you write that
last clause as
 	remove_leading_blanks([H|T], L) :-
 		(   H =:= " ",
 	            remove_leading_blanks(T, L)
		;   H =\= " ",
		    L = [H|T]
		).
and the compiler is smart enough to notice that the two tests conflict,
and it will plant the cut for you.  That's the _really_ nice way to write it.
(Does the new Berkeley compiler do this too?)
-- 
The taxonomy of Pleistocene equids is in a state of confusion.
Technical Details
Message-ID: <3553@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!munnari.oz.au!goanna!ok
References: <2157@cernvax.UUCP> <3542@goanna.cs.rmit.oz.au> <24120@megaron.cs.arizona.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!munnari.oz.au!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: Simple Prolog Question
Message-ID: <3553@goanna.cs.rmit.oz.au>
Date: 13 Aug 90 07:07:58 GMT
References: <2157@cernvax.UUCP> <3542@goanna.cs.rmit.oz.au> <24120@megaron.cs.arizona.edu>
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 31