Skip to content

Instantly share code, notes, and snippets.

@Josh-Tilles
Josh-Tilles / Praxis19Aug2011.rkt
Created September 8, 2011 23:02
Programming Praxis 19 Aug 2011 (first non-repeating char) solution in PLT Racket
#lang racket
(define (first-uniq chars)
(when (empty? chars)
(raise "There are no unique letters"))
(let ([c (first chars)])
(if (memq c (rest chars)) ; MEMQ is like MEMBER with EQ?
(first-uniq (remq* (list c) chars)) ; N.B the tail-recursion here
c)))