Skip to content

Instantly share code, notes, and snippets.

@stevewillard
Created October 7, 2008 02:20
Show Gist options
  • Save stevewillard/15217 to your computer and use it in GitHub Desktop.
Save stevewillard/15217 to your computer and use it in GitHub Desktop.
> module Scan where
> import Char
> tokenize [] = []
> tokenize (x:xs)
> | isSpace x = tokenize xs
> | isDigit x = fst (span isDigit (x:xs)) : tokenize (snd (span isDigit (x:xs)))
> | isAlpha x = fst (span isAlpha (x:xs)) : tokenize (snd (span isAlpha (x:xs)))
> | isSym x = fst (span isSym (x:xs)) : tokenize (snd (span isSym (x:xs)))
> isSym c = c `elem` "!@#$%&*+./<=>?\\^|:-~()"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment