Loading [MathJax]/extensions/tex2jax.js

2010年7月15日木曜日

Extract a slice from a list

;; P18 (**) Extract a slice from a list.
;; Given two indices, I and K, the slice is the list containing the elements between the I'th and K'th element of the original list (both limits included). Start counting the elements with 1.
;; Example:
;; * (slice '(a b c d e f g h i k) 3 7)
;; (C D E F G)
(require srfi/1)
(define (slice lst i k)
(drop (take lst k) (- i 1)))
view raw p18.ss hosted with ❤ by GitHub

0 件のコメント:

コメントを投稿