2010年7月15日木曜日

Find the last but one box of a list

;; P02 (*) Find the last but one box of a list.
;; Example:
;; * (my-but-last '(a b c d))
;; (C D)
(define (my-but-last lst)
(let ((revlis (reverse lst)))
(cond
((null? revlis) '())
((< (length revlis) 3) lst)
(else `(,(cadr revlis) ,(car revlis))))))
view raw p02.ss hosted with ❤ by GitHub

0 件のコメント:

コメントを投稿