P15 (**) Replicate the elements of a list a given number of times.
来源:互联网 发布:笑气在淘宝怎么搜 编辑:程序博客网 时间:2024/04/28 21:31
问题描述
sash> (repli '(a b c) 3)sash> (a a a b b b c c c)
解法
(define repli (lambda (ls n) (let f ([s ls] [m n]) (if (null? s) '() (if (zero? m) (f (cdr s) n) (let ([e (car s)]) (cons e (f s (- m 1)))))))))
与上一个P14类似,也可将每个元素重复形成相应的子列表,然后用append
拼接起来。
1 0
- P15 (**) Replicate the elements of a list a given number of times.
- P14 (*) -P15 (**)Duplicate the elements of a list,Duplicate the elements of a list a given number of
- P23 (**) Extract a given number of randomly selected elements from a list.
- P14 (*) Duplicate the elements of a list.
- Write a method that counts the number of occurrences of a given character in a string
- Repeat Part of the Regex a Certain Number of Times (重复匹配中的部分)
- Finding a number that repeats even no of times where all the other numbers repeat odd no of times
- Binary representation of a given number
- All factors of a given number
- P25 (*) Generate a random permutation of the elements of a list.
- Given a non-empty array of integers, return the k most frequent elements.
- Write a Servlet Application that uses a cookie to track the number of times a user visits a web site
- P26 (**) Generate the combinations of K distinct objects chosen from the N elements of a list.
- A. The number of positions
- MACRO of a method of loop list for visit elements
- P17 (*) Split a list into two parts; the length of the first part is given.
- Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or
- [CrackCode] 4.4 Creates a linked list of all the nodes at each depth of a given tree
- 拷贝既存excel文件sheet方法
- Vijos P1016 钟表问题 BFS+剪枝
- (转)编译原理简述 (预处理>编译>汇编>链接)
- 抽象类与接口(对比总结)
- 输出亲朋字符串
- P15 (**) Replicate the elements of a list a given number of times.
- linux查看各种硬件信息的方法
- iOS多线程之GCD学习
- JAVA——常见IO流的使用
- 45度斜角地图菱形坐标转换
- POJ 1797 Heavy Transportation
- linux下手动build spark1.6.0
- 匿名内部类那点事
- 哈夫曼树结构体数组生成方法