DigitalDreams
06-22-2008, 08:13 PM
Hi All,
I am currently learning haskell and trying to make a small program that defines the following gates: AND,OR,NAND,NOR,NOT,XOR
so far i have the following code below:
but for some reason the not function works on its own, but when i put it with the following code below, i get the following error.
Syntax error in input (unexpected `=`)
It would be great if someone code have a look and tell me what i have done wrong, Thanks
> and :: Bool -> Bool -> Bool
> and a b = a&&b
> or :: Bool -> Bool -> Bool
> or a b = a||b
> not :: Bool -> Bool
> not True = False
> not False = True
> nand :: Bool -> Bool -> Bool
> nand a b = not (a `and` b)
> nor :: Bool -> Bool -> Bool
> nor a b = not (a `and` b)
> xor :: Bool -> Bool -> Bool
> xor a b = (a `or` b) `and` (not (a `and` b))
I am currently learning haskell and trying to make a small program that defines the following gates: AND,OR,NAND,NOR,NOT,XOR
so far i have the following code below:
but for some reason the not function works on its own, but when i put it with the following code below, i get the following error.
Syntax error in input (unexpected `=`)
It would be great if someone code have a look and tell me what i have done wrong, Thanks
> and :: Bool -> Bool -> Bool
> and a b = a&&b
> or :: Bool -> Bool -> Bool
> or a b = a||b
> not :: Bool -> Bool
> not True = False
> not False = True
> nand :: Bool -> Bool -> Bool
> nand a b = not (a `and` b)
> nor :: Bool -> Bool -> Bool
> nor a b = not (a `and` b)
> xor :: Bool -> Bool -> Bool
> xor a b = (a `or` b) `and` (not (a `and` b))