Constructing Cases
Carl McTague
mctague@one.net
Fri, 24 May 2002 09:32:26 -0400
Hi there,
is there a simple way to carry out the following type of conversion?
Suppose I have a list (finite) of (value,image) pairs such as:
list = [(0,1),(1,0)]
>From this I want to generate a function
f 0 = 1
f 1 = 0
Is there a way to do this? Note, I don't want to define a function
that searches through the list each time it is invoked, I want to
generate the function once and have it be as fast as the
pattern-matcher can make it.
So, I'm looking for a function g :: [(a,b)] -> a -> b
Is this simple to do?
Thanks,
Carl