Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

HOST SYSTEM NOT RESPONDING, PROBABLY DOWN. DO YOU WANT TO WAIT? (Y/N)


devel / comp.lang.lisp / .Re: cloning elements in a list

SubjectAuthor
o .Re: cloning elements in a listRobert L.

1
.Re: cloning elements in a list

<sv3t11$4rb$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16916&group=comp.lang.lisp#16916

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!fOOSGi8kPW/6s17dnklhsg.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: cloning elements in a list
Date: Tue, 22 Feb 2022 23:53:07 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sv3t11$4rb$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="4971"; posting-host="fOOSGi8kPW/6s17dnklhsg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Tue, 22 Feb 2022 23:53 UTC

> > How to write a lisp function which clones the top-level elements of a list
> L
> > (first arguement) n ( second argument) times. for eg. (clone 'A B C) 4 )
> > produces ( AAAABBBBCCCC)
>
> To rewrite your question to what I *think* you mean:
> (clone '(A B C) 4 )
> => (A A A A B B B B C C C C)
>
> try this:
> CL-USER 143 > (defun stretch (list factor)
> (loop for elt in list
> nconc (make-list factor :initial-element elt)))
> STRETCH
>
> CL-USER 144 > (stretch '(a b c) 4)
> (A A A A B B B B C C C C)

Scheme:

(define (stretch lst factor . xs)
(if (zero? factor)
(apply append-map list xs)
(apply stretch lst (- factor 1) (cons lst xs))))

(stretch '(a b c) 4)
===>
(a a a a b b b b c c c c)


devel / comp.lang.lisp / .Re: cloning elements in a list

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor