Path: 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 > 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.