Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Keep emotionally active. Cater to your favorite neurosis.


comp / comp.lang.lisp / Re: Help with GA, and critique my Lisp (please ;-))

SubjectAuthor
* Re: Help with GA, and critique my Lisp (please ;-))B. Pym
`- Re: Help with GA, and critique my Lisp (please ;-))Kaz Kylheku

1
Subject: Re: Help with GA, and critique my Lisp (please ;-))
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 26 Sep 2024 02:27 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (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: <vd2gqh$1c8r$1@dont-email.me>
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=
View all headers

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))

Subject: Re: Help with GA, and critique my Lisp (please ;-))
From: Kaz Kylheku
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Thu, 26 Sep 2024 03:53 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp,comp.lang.scheme
Subject: Re: Help with GA, and critique my Lisp (please ;-))
Date: Thu, 26 Sep 2024 03:53:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <20240925205127.543@kylheku.com>
References: <vd2gqh$1c8r$1@dont-email.me>
Injection-Date: Thu, 26 Sep 2024 05:53:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6301191434da988399c4b082ba0fe62f";
logging-data="63654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DNvpU+ZvBwRsb19FXd/QyFopa+7ad510="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:M/cEXLc0WbfxLCZHTlRGm29ATjw=
View all headers

On 2024-09-26, B. Pym <Nobody447095@here-nor-there.org> wrote:
> 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))

TXR Lisp:

1> (poly 0.5 '(2 3 4))
6.0
2> (rpoly 0.5 '(2 3 4))
4.5

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

1

rocksolid light 0.9.8
clearnet tor