Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Truth will out this morning. (Which may really mess things up.)


comp / comp.lang.lisp / Re: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???

SubjectAuthor
* Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???HenHanna
`- Re: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???Kaz Kylheku

1
Subject: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 20:35 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp
Subject: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???
Date: Tue, 18 Jun 2024 13:35:30 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <v4sr2j$1gg3l$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 22:35:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1ff5838eddcfee2869179dd23adb7000";
logging-data="1589365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+b0ZH+FEAwZSVs/+su2HpVBsK8v62mvOM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3sH+mJiaCAV5db1VGQZUDV4DvUk=
Content-Language: en-US
View all headers

1. Is there a better way to define Or-Func ?

2. (make-list x) works well here. What else is it good for?

3. What is (make-list 3) in MIT Scheme?
Should (length (make-list 3)) raise an Error?

(define (or-func2 x y) (or x y))
(define or-func (lambda x (fold or-func2 #t x)))

(define (fact x)
(fold * 1
(map or-func (make-list x) (lrange 1))))

(print (fact 0))
(print (fact 1))
(print (fact 3))
(print (fact 5))
(print (fact 10))

Subject: Re: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 01:03 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
Subject: Re: Or-Func, What is (make-list 3) good for? (besides
Lazy-factorial) ???
Date: Wed, 19 Jun 2024 01:03:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <20240618154203.967@kylheku.com>
References: <v4sr2j$1gg3l$3@dont-email.me>
Injection-Date: Wed, 19 Jun 2024 03:03:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a089f22f6620d85d02f1b703c80c4bae";
logging-data="1711380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+AVwMpXTp0QAVF2Ryqb25veQGbC6GRuCc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:5+LvbxDhYDF/XjdRUOaQoh+66vQ=
View all headers

On 2024-06-18, HenHanna <HenHanna@devnull.tb> wrote:
>
> 1. Is there a better way to define Or-Func ?
>
> 2. (make-list x) works well here. What else is it good for?
>
> 3. What is (make-list 3) in MIT Scheme?
> Should (length (make-list 3)) raise an Error?
>
>
>
> (define (or-func2 x y) (or x y))
> (define or-func (lambda x (fold or-func2 #t x)))
>
> (define (fact x)
> (fold * 1
> (map or-func (make-list x) (lrange 1))))
>
> (print (fact 0))
> (print (fact 1))
> (print (fact 3))
> (print (fact 5))
> (print (fact 10))

This is the TXR Lisp interactive listener of TXR 294.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
If you get your macros hot enough, you get syntactic caramel!
1> (fboundp 'or)
t 2> (mboundp 'or)
nil
3> (special-operator-p 'or)
t 4> (mapcar 'or '(1 nil nil 4) '(10 20 30 40))
(1 20 30 4)

No "or-func" required; or as a function can be provided in the language.

We can have a Lisp dialect that allows us to bind the same symbol in both the
macro/operator space and the function space.

This causes no issues.

When (or ...) syntax is processed, the operator or macro is activated.
All other other function-like uses of the symbol go through the function
binding.

This design obviates the need for compiler macros (define-compiler-macro). For
any given function, we can write an ordinary macro. That macro is always used,
when the function is syntactically invoked.

We must imbue ordinary macros with the ability to decline exmpansion by
returning the original form; the expander must stop expanding when it
hits a fixed point, according ot the EQ function (expander in is EQ
to expander out).

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