All pastes #231323 Raw Edit

Miscellany

public text v1 · immutable
#231323 ·published 2006-10-31 19:30 UTC
rendered paste body
(define (drop-first alon n)
  (cond [(>= n (length alon)) empty]
        [(= n 0) alon]
        [else (drop-first (rest alon) (sub1 n))]))

(define (keep-first alon n)
  (cond [(>= n (length alon)) alon]
        [(= n 0) empty]
        [else (cons (first alon) (keep-first (rest alon) (sub1 n)))]))

(define (DNAprefix pattern search-string)
  (cond [(equal? pattern (keep-first search-string (length pattern))) true]
        [else false]))

(define (DNAsubstring pattern search-string)
  (cond [(empty? search-string) false]
        [(DNAprefix pattern search-string) true]
        [else (DNAsubstring pattern (drop-first search-string 1))]))