🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1048

Simple Prolog Question

#1048
From: julian bunn
Date: Wed, 08 Aug 1990 15:37
19 lines
789 bytes
Can some kind person please help with a trivial Prolog problem?
I am trying to write a program that will remove leading blank
characters from a list. For example, the result of:

remove_blanks([32,32,32,104,104],X).

should be:

X = [104,104]

I have tried, with reckless abandon, the following definition:

remove_blanks([H|T],T) :- H=32, remove_blanks(T,_).
remove_blanks(S,S).

which, when tracing, seems to do nicely recursively, but in the
end returns me with T equal to the original list!

Help !
Technical Details
Message-ID: <2157@cernvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!cernvax!julian

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!cernvax!julian
From: julian@cernvax.UUCP (julian bunn)
Newsgroups: comp.lang.prolog
Subject: Simple Prolog Question
Message-ID: <2157@cernvax.UUCP>
Date: 8 Aug 90 15:37:35 GMT
Organization: CERN, Geneva, Switzerland
Lines: 19