| Deutsch English Français Italiano |
|
<20240618154203.967@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> 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= Bytes: 2772 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