Substrings in Scheme

Reading time ~1 minute

I wrote this today.

(define substring?
  (lambda (pat str)
      (sublist? (string->list pat) (string->list str))))

(define sublist?
  (lambda (pat ls)
      (define (sublist-check pat ls pat-length ls-length)
          [(> pat-length ls-length) #f]
          [(equal? pat (list-head ls pat-length)) #t]
          [else (sublist-check pat (cdr ls) pat-length (sub1 ls-length))]))
    (sublist-check pat ls (length pat) (length ls))))

Here it is for the next poor soul.

Using LaTeX for Programming Language Semantics

LaTex is a fantastic tool for typesetting, but there seem to be a serious gapin documentation for using it to lay out programming semanti...… Continue reading

A Small ALU in Haskell, Part I

Published on April 24, 2015

The Refined Gradual Guarantee and Compilation

Published on April 15, 2015