Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You're currently going through a difficult transition period called "Life."


comp / comp.lang.scheme / Re: What to do with (time (length L)) proportional to (length L)

SubjectAuthor
* Re: What to do with (time (length L)) proportional to (length L)B. Pym
`- Re: What to do with (time (length L)) proportional to (length L)B. Pym

1
Subject: Re: What to do with (time (length L)) proportional to (length L)
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Sat, 21 Sep 2024 14:58 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: What to do with (time (length L)) proportional to (length L)
Date: Sat, 21 Sep 2024 14:58:42 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <vcmmv0$1ks6r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Sat, 21 Sep 2024 16:58:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="75bf4db5387dcb76189623713453f22d";
logging-data="1732827"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wvxjQ7DrR4VYGxz/C8b1s"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:A1c9GxoAHX36lIWNtYAqH4qcZFU=
View all headers

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

Subject: Re: What to do with (time (length L)) proportional to (length L)
From: B. Pym
Newsgroups: comp.lang.lisp, comp.lang.scheme
Organization: A noiseless patient Spider
Date: Sat, 21 Sep 2024 21:55 UTC
References: 1
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: What to do with (time (length L)) proportional to (length L)
Date: Sat, 21 Sep 2024 21:55:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <vcnfd8$1oelo$1@dont-email.me>
References: <vcmmv0$1ks6r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Sat, 21 Sep 2024 23:55:53 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d5f01ce3b215258a34bb2869ac4b2d21";
logging-data="1850040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+N1CNLfbOWMimvzA0hKTNw"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:jAO9udyPNx8Ufud26npMuhujeWo=
View all headers

B. Pym wrote:

> > (loop for elem in some-list
> > collect (f4 (f3 (f2 (f1 elem)))))
>
> (map (~> abs sqrt list) '(-4 -9 25))
>
> ===>
> ((2) (3) (5))

(map (~> abs sqrt list (append '(finished))) '(-4 -9 25))
===>
((2 finished) (3 finished) (5 finished))

1

rocksolid light 0.9.8
clearnet tor