Article View: comp.lang.prolog
Article #2395Re: Help !!
From: C. M. Sperberg-McQueen
Date: Thu, 21 Jan 1993 21:48
Date: Thu, 21 Jan 1993 21:48
20 lines
1557 bytes
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
Technical Details
Message-ID:
<93021.154835U35395@uicvm.uic.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u35395References:
<1iv7leINNsc4@rave.larc.nasa.gov> <lenn.726916615@du9ds4> <j_hamer-210193105028@john-ha.cs.aukuni.ac.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u35395 Organization: University of Illinois at Chicago Date: Thu, 21 Jan 1993 15:48:35 CST From: C. M. Sperberg-McQueen <U35395@uicvm.uic.edu> Message-ID: <93021.154835U35395@uicvm.uic.edu> Newsgroups: comp.lang.prolog Subject: Re: Help !! References: <1iv7leINNsc4@rave.larc.nasa.gov> <lenn.726916615@du9ds4> <j_hamer-210193105028@john-ha.cs.aukuni.ac.nz> Lines: 20