Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "B. Pym" Newsgroups: comp.lang.lisp,comp.lang.scheme Subject: Re: Help with GA, and critique my Lisp (please ;-)) Date: Thu, 26 Sep 2024 02:27:30 -0000 (UTC) Organization: A noiseless patient Spider Lines: 28 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Thu, 26 Sep 2024 04:27:31 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2b7f8b0e9338bb313cc30be8fc596d5b"; logging-data="45339"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cB8bgDezbBxYdkdwPev4b" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:SXeEPswK9mzFXjH89kwsZvnqktU= Bytes: 1604 Geoffrey Summerhayes wrote: > > > > (defun evaluate-poly (p x) > > (loop for coeff in p > > for power from 0 > > sum (* coeff (expt x power))) > > > > A little wasteful, but what the heck. > > > > (defun evaluate-poly (p x) > (reduce #'(lambda (a c) (+ c (* x a))) > (reverse p) :initial-value 0)) It ought to be "(lambda", not "#'(lambda". However, disciples of CL (COBOL-Like) always try to make their code as ugly and as prolix as possible. He would have been even more pleased if he could have written: (#'reduce #'#'#'#'#'#'#'#'#'(lambda (a c) (#'+ c (#'* x a))) Gauche Scheme: (define (eval-poly p x) (fold-right (^(c a) (+ c (* x a))) 0 p))