Date: Thu, 20 Sep 2002 11:53:22 -0400 From: Li Liao <lliao@mail.eecis.udel.edu> Subject: Re: homework question > And here is one more question for ex1: > it's fairly easy to write a funcion for ex1 if we consider only simle > strings like: > Repeat(Char #"a"); Char #"a" > The function will look like this > fun canBeEmpty Empty = true > | canBeEmpty (Repeat a) = true > | canBeEmpty (Alt (a, b))= false > | canBeEmpty (Conc (a, b))=false > | canBeEmpty (Char a) = false; > But we consider more complicated regular expressions like: Alt(Conc(Char > #"a", Repeat(Char #"b")), Conc(Repeat(Char #"a"),Char #"b")) > we'll have to parse the string and consider every case, if any Repeat or > Empty is found, we'll return true. What is the best way to parse this string > in ML and do comparisons? Remember the power of recursion.