Article View: comp.lang.prolog
Article #3630Re: Soundex revisited
From: Mattias Waldau
Date: Fri, 02 Sep 1988 10:09
Date: Fri, 02 Sep 1988 10:09
38 lines
1925 bytes
1925 bytes
R.O'Keefe points out that my specification of < is wrong, thank you.
He also says that his program should be easier to understand since it
is shorter, but I say that this only holds under the assumption that
you have to read the whole program to understand what it describes.
An example: we want to define the relation that removes the vowels
from a sequence of letters. In Prolog we would have to write a
recursive program like
remove_vowels([], []).
remove_vowels([Vowel|With], Without) :-
vowel(Vowel),
remove_vowels(With, Without).
remove_vovels([Not_a_vowel|With], [Not_a_vowel|Without]) :-
not_a_vowel(Not_a_vowel),
remove_vowels(With, Without).
If we have an explicit definition of not_a_vowel this program can also
be used backwards.
If we had full first order logic we could instead write
remove_vowels(With, Without) <->
subsequence(Without, With) &
(Elements){Element in Without -> ~vowel(Element)}
saying that Without must be a subsequence of With and all elements of
Without are nonvowels. It is assumed that the predicates subsequence
and in are already understood by the programmer, so the number of NEW
symbols that he has to write/understand are fewer then in the Prolog
example above.
I generally believe that quantifiers are easier to understand than
recursion, but if we have recursive datastructures we still have to use
recursion when defining primitive relations like in and subsequence.
--
Mattias Waldau
Technical Details
Message-ID:
<818@kuling.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!mcvax!enea!kth!draken!bmc1!kuling!waldauReferences:
<1178@tuhold> <816@kuling.UUCP> <334@quintus.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!mcvax!enea!kth!draken!bmc1!kuling!waldau From: waldau@kuling.UUCP (Mattias Waldau) Newsgroups: comp.lang.prolog Subject: Re: Soundex revisited Message-ID: <818@kuling.UUCP> Date: 2 Sep 88 10:09:28 GMT References: <1178@tuhold> <816@kuling.UUCP> <334@quintus.UUCP> Reply-To: waldau@kuling.UUCP (Mattias Waldau) Organization: UPMAIL, Computing Science Department, Uppsala University, Sweden Lines: 38