module Fixwords where --Given a Word, strips leading and trailing non-alphabetic characters (such --characters in the middle of a word are not removed), and converts it to lower --case. --import Prelude type Word = [Char] type Line = [Word] stripTP :: Word->Word stripTP [] = [] stripTP (x:xs) |(isAlpha (last (x:xs))) = x:xs |otherwise = if null xs then [] else stripTP (x:init xs) stripLP :: Word->Word stripLP [] = [] stripLP (x:xs) |(isAlpha x) = x:xs |otherwise = stripLP xs stripPunct:: Word->Word stripPunct [] = [] stripPunct (x:xs) = stripTP (stripLP (x:xs)) lowerCase :: Word->Word lowerCase [] = [] lowerCase (x:xs) = (toLower x):(lowerCase xs) fixWord :: Word->Word fixWord [] = [] fixWord (x:xs) = lowerCase(stripPunct(x:xs))