Re: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???

Liste des GroupesRevenir à cl lisp 
Sujet : Re: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 19. Jun 2024, 03:03:46
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240618154203.967@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
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

Date Sujet#  Auteur
18 Jun 24 * Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???2HenHanna
19 Jun 24 `- Re: Or-Func, What is (make-list 3) good for? (besides Lazy-factorial) ???1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal