PasteRack.org
Paste # 95162
2017-02-23 11:25:36

Fork as a new paste.

Paste viewed 338 times.


Embed:

  1. #lang racket
  2.         (define (prefix-of prefix str)
  3.          (let loop ((prefix2 (string->list prefix))
  4.                  (str2 (string->list str)));
  5.                  (cond ((null? prefix2) #t)
  6.                  ((null? str2) #f)
  7.                  ((equal? (car prefix2) (car str2))
  8.                 (loop (cdr prefix2) (cdr str2)))
  9.                  (else #f))))
  10.  
  11.  
  12. (prefix-of '(a b) '(a b c))

=>

string->list: contract violation

  expected: string?

  given: '(a b)