Skip to content

Commit

Permalink
Update ahead_one_step.md
Browse files Browse the repository at this point in the history
提供一个 racket 5.2.1 的解法
  • Loading branch information
pimgeek committed Jun 3, 2014
1 parent 16ce05d commit 1b62a1a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ahead_one_step.md
Expand Up @@ -18,3 +18,19 @@

if __name__ =="__main__":
print ahead_one()

#解决(racket 5.2.1)

```racket
#lang racket
; 定义函数 ahead-one
; 输入为一个整数列表 int-list,假设其长度为 N
; 输出为长度相同的整数列表,其第 N 位的元素为 int-list 的第 1 位的元素,
; 其 1~N-1 位的元素为 int-list 的第 2~N 位的元素
(define (ahead-one int-list)
(append (rest int-list) (list (first int-list))))
; 函数调用,正常运行时应输出 '(2 3 4 5 6 7 8 9 10 1)
(ahead-one (list 1 2 3 4 5 6 7 8 9 10))
```

0 comments on commit 1b62a1a

Please sign in to comment.