Seems like the function is easy to define:replaceIfEq a b c = if c == a then b else cThen the above can be writtenreplaceIfEq Foo Bar valueOr the slightly more general (in exchange for slightly more verbosity at the call site)replaceIf p r a = if p a then r else areplaceIf (== Foo) Bar valueOn Fri, Dec 21, 2012 at 6:46 PM, Radical <radical@google.com> wrote:
Sometimes I'll need something like:if value == Foo then Bar else valueOr some syntactic variation thereof:case value of { Foo -> Bar; _ -> value }Is there a better/shorter way to do it? I'm surprised that it's more complicated to substitute a value on its own than e.g. in a list, using filter. Or perhaps I'm missing the right abstraction?Thanks,Alvaro_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe