Arc Cross Reference

subseq

[procedure] subseq seq start (o end (len seq))

Takes subsequence of a sequence seq, starting from start and ending at end.

(def subseq (seq start (o end (len seq)))
  (if (isa seq 'string)
      (let s2 (newstring (- end start))
        (for i 0 (- end start 1)
          (= (s2 i) (seq (+ start i))))
        s2)
      (firstn (- end start) (nthcdr start seq))))

Gauche has the generic function of the same name: scheme:subseq.

Categorys:sequence