The general Lisp equivalent of Haskell replication?

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

eg. replicate 3 ["a"] returns ["a", "a", "a"]

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

+4
source share
2 answers

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

HyperSpec

+4
source

Use make-list

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

He appreciates

 (AAA) 
+6
source

Source: https://habr.com/ru/post/1346290/


All Articles