Ternary logic: Difference between revisions
Content added Content deleted
(→{{header|Groovy}}: new solution) |
(→{{header|OCaml}}: simplified function logic) |
||
Line 1,574: | Line 1,574: | ||
| Maybe -> Maybe |
| Maybe -> Maybe |
||
let t_and a b = |
let t_and a b = match (a,b) with |
||
⚫ | |||
match a with |
|||
| |
| (False,_) | (_,False) -> False |
||
| |
| _ -> Maybe |
||
| Maybe -> |
|||
match b with |
|||
| False -> False |
|||
| _ -> Maybe |
|||
let t_or a b = |
let t_or a b = t_not (t_and (t_not a) (t_not b)) |
||
match a with |
|||
| True -> True |
|||
| False -> b |
|||
| Maybe -> |
|||
match b with |
|||
| True -> True |
|||
| _ -> Maybe |
|||
let t_eq a b = |
let t_eq a b = match (a,b) with |
||
⚫ | |||
match a with |
|||
| True -> |
| (False,True) | (True,False) -> False |
||
| |
| _ -> Maybe |
||
| False -> |
|||
match b with |
|||
| True -> False |
|||
⚫ | |||
| Maybe -> Maybe |
|||
let t_imply a b = |
let t_imply a b = t_or (t_not a) b |
||
match a, b with |
|||
⚫ | |||
| True, b -> b |
|||
| False, _ -> True |
|||
| Maybe, _ -> Maybe |
|||
let string_of_trit = function |
let string_of_trit = function |