Article View: comp.lang.prolog
Article #2779Standard of Prolog code
From: Lee Naish
Date: Sun, 27 Sep 1987 04:28
Date: Sun, 27 Sep 1987 04:28
25 lines
1562 bytes
1562 bytes
Virtually every time someone posts Prolog code to the network I groan. I see code like this: >merge([],[],[]). >merge([],List2,List2):- !, fail. >merge(List1,[],List1):- !, fail. >merge([Head1|Tail1],[Head2|Tail2],[Head1,Head2|R]):- merge(Tail1,Tail2,R), !. I wince, I tear my hair out, I fall to my knees and bang my head against the nearest rock crying; is this the Prolog code people write? What happened to logic programming? Am I wasting my time? Then I compose myself. I grit my teeth, take hold of my electronic butchers knife and attack the code. Out with the filth! Out with the cuts, the dirty negation, the asserts. Wash it clean. Just leave the essence; pure beautiful logic: merge([],[],[]). merge(Head1.Tail1, Head2.Tail2, Head1.Head2.R) :- merge(Tail1,Tail2,R). Then I look on it anew. I see it can be run as Prolog. No choice point will be created! It will be fast! It can be run backwards! It can be run any way need dictates. I breath a sigh of relief and my confidence in logic programming and Prolog are restored.
Technical Details
Message-ID:
<2265@mulga.oz>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!munnari!mulga!leeShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!munnari!mulga!lee From: lee@mulga.oz (Lee Naish) Newsgroups: comp.lang.prolog Subject: Standard of Prolog code Message-ID: <2265@mulga.oz> Date: Sun, 27-Sep-87 00:28:45 EDT Article-I.D.: mulga.2265 Posted: Sun Sep 27 00:28:45 1987 Date-Received: Mon, 28-Sep-87 01:43:37 EDT Reply-To: lee@mulga.UUCP (Lee Naish) Distribution: world Organization: Comp Sci, Melbourne Uni, Australia Lines: 25