5

replicate is a function that takes an integer and a sequence and returns the sequence repeated n times.

E.g. replicate 3 ["a"] returns ["a", "a", "a"]

Does Common Lisp have an equivalent function, or do I have to write one?

mcandre
  • 22,868
  • 20
  • 88
  • 147

2 Answers2

7

Use make-list

(make-list 3 :initial-element 'a)

It evaluates to

(A A A)
Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
augustss
  • 22,884
  • 5
  • 56
  • 93
5

(make-sequence 'list n :initial-element element)

HyperSpec

mcandre
  • 22,868
  • 20
  • 88
  • 147
wnoise
  • 9,764
  • 37
  • 47