schemeでリスト中に同じ要素が並んでいるか判定する

(define (is-prefix xs ys)
  (if (null? xs) #t
      (if (null? ys) #f
          (if (eq? (car xs) (car ys))
              (is-prefix (cdr xs) (cdr ys))
              #f))))

(define (match xs ys)
     (if (null? ys) #f
         (if (is-prefix xs ys) #t
             (match xs (cdr ys)))))

(print (match '(3 5) '(1 2 3 4 5)))

しまった文字列ならstring-scanで終わりじゃないか。

>>(string-scan "abcdefcabcd" "def")
=>3