This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; P15 (**) Replicate the elements of a list a given number of times. | |
;; Example: | |
;; * (repli '(a b c) 3) | |
;; (A A A B B B C C C) | |
(define (repli lst int) | |
(let loop ((lst lst) (i int) (acc '())) | |
(cond ((null? lst) (reverse acc)) | |
((< i 1) (loop (cdr lst) int acc)) | |
(else (loop lst (- i 1) (cons (car lst) acc)))))) |
0 件のコメント:
コメントを投稿