Re: What to do with (time (length L)) proportional to (length L)

Liste des GroupesRevenir à cl scheme 
Sujet : Re: What to do with (time (length L)) proportional to (length L)
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.scheme
Date : 21. Sep 2024, 15:58:42
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vcmmv0$1ks6r$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Pascal Costanza wrote:

(let* ((temp1 (mapcar #'f1 some-list))
        (temp2 (mapcar #'f2 temp1))
        (temp3 (mapcar #'f3 temp2)))
   (mapcar #'f4 temp3))
 
You could better say:
 
(loop for elem in some-list
       collect (f4 (f3 (f2 (f1 elem)))))

(map (~> abs sqrt list) '(-4 -9 25))

  ===>
((2) (3) (5))

Given:

(define-syntax ->>
  (syntax-rules ()
    [(_ x)  x]
    [(_ x (y ...) z ...)
     (->> (y ... x) z ...)]
    [(_ x y z ...)
     (->> (y x) z ...)]))

(define-syntax ->
  (syntax-rules ()
    [(_ x)  x]
    [(_ x (y more ...) z ...)
     (-> (y x more ...) z ...)]
    [(_ x y z ...)
     (-> (y x) z ...)]))

;; currying
(define-syntax ~>
  (syntax-rules ()
    [(_ func0 func ...)
     (lambda xs (-> (apply func0 xs) func ...))]))

Date Sujet#  Auteur
21 Sep 24 * Re: What to do with (time (length L)) proportional to (length L)2B. Pym
21 Sep 24 `- Re: What to do with (time (length L)) proportional to (length L)1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal