William James
7/23/2015 8:10:00 PM
Coby Beck wrote:
> > How to write a lisp function which clones the top-level elements of a list
> > (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)
Gauche Scheme:
(use srfi-42 :only (append-ec))
(define (stretch items n)
(append-ec (: x items) (make-list n x)))
(stretch '(a b c) 4)
===>
(a a a a b b b b c c c c)
--
Under the disguise of liberalism, humanism, and democracy, Europeans have been
persuaded to commit racial suicide -- a race that has achieved so much and has
survived so much has been tricked into welcoming its own downfall and to take
active measures in order to become a stranger on its own soil.
www.kolumbus.fi/aquilon/moscowspeech2010.htm