🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.prolog
3 messages
3 total messages Started by Mike Goodrich Tue, 12 Jan 1993 19:54
Help !!
#2471
Author: Mike Goodrich
Date: Tue, 12 Jan 1993 19:54
9 lines
756 bytes
Greetings,
	As a Prolog neophyte, I am having some diffuculty. Can anyone show me a set of
clauses for a predicate which can search a list of integers and return the maximum int to
the parent clause ? Even if there is a built-in predicate, I still need it for other
purposes. Thanx...


..mike
Re: Help !!
#2395
Author: C. M. Sperberg-McQueen
Date: Thu, 21 Jan 1993 21:48
20 lines
1557 bytes
> How do you go about writing an elegant, efficient solution?  For a start,
> DO NOT TRY TO WRITE IT AS A LOGIC PROGRAM!  What you want is a *function*
> from a list of integers to an integer (no backtracking to multiple
> solutions, or solving for either argument is needed).  Therefore, your
> solution should be written in a functional style.  Most students would have
> little trouble in coming up with the following functional solution (in
> Pascal):

If you wanted to write it in Pascal, why didn't you just compile it
in Pascal?  Heiner's program may well run longer than yours.  On the
other hand it is shorter, and much easier to see that it is correct.
Since my machines spend far more time waiting for my keystrokes than
they do working, I see no reason to worry about making code run faster
unless it is now running too slow.  Sufficient unto the day is the
evil thereof; why should I worry about trivial 'inefficiencies' like
those you see in Heiner's code, until they are making my work
unacceptably slow?

-C. M. Sperberg-McQueen
 University of Illinois at Chicago
Re: Help !!
#2416
Author: j_hamer
Date: Mon, 25 Jan 1993 21:47
26 lines
1916 bytes
In article <93021.154835U35395@uicvm.uic.edu>, C. M. Sperberg-McQueen
<U35395@uicvm.uic.edu> wrote:
> 
> If you wanted to write it in Pascal, why didn't you just compile it
> in Pascal?  Heiner's program may well run longer than yours.  On the
> other hand it is shorter, and much easier to see that it is correct.
> Since my machines spend far more time waiting for my keystrokes than
> they do working, I see no reason to worry about making code run faster
> unless it is now running too slow.  Sufficient unto the day is the
> evil thereof; why should I worry about trivial 'inefficiencies' like
> those you see in Heiner's code, until they are making my work
> unacceptably slow?
> 
> -C. M. Sperberg-McQueen
>  University of Illinois at Chicago

I am not particularly worried about the performance of Heiner's program (it
is lousy, but this is no immediate concern to a beginner).  It seemed to me
that Mike's original posting was asking for some guidance, not a quick
hack.  Quite simply, if you want to develop from a Prolog beginner into a
proficient Prolog programmer, then you will spend your time studying good
code.

-- John Hamer                           Email: J_Hamer@cs.aukuni.ac.nz
-- Department of Computer Science
-- University of Auckland, New Zealand.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads