[Haskell-cafe] Building ? using kleene closure {not haskell specific}

Sebastian Fischer fischer at nii.ac.jp
Fri Aug 12 13:04:28 CEST 2011

> I can easily understand how + can be built but am having trouble with
> building ? (zero or one).

If there is a regular expression e for the empty word, one can define ? as

    a? = e | a

If there is a regular expression o that never matches one can define e as

    e = o*

If there are character classes one can define o as

    o = []

Apart from that, I have no idea..


More information about the Haskell-Cafe mailing list