Twelve statements: Difference between revisions
Content deleted Content added
→{{header|Haskell}}: using unicode operators. Might not be a terribly smart thing to do, those who know haskell, feel free to change it |
|||
Line 25: | Line 25: | ||
tf (x:xs) = map (True:) s ++ map (False:) s where s = tf xs |
tf (x:xs) = map (True:) s ++ map (False:) s where s = tf xs |
||
sumbool = |
sumbool = length . filter id |
||
wrongness b = sumbool . zipWith (/=) b . map (\f -> f b) |
wrongness b = sumbool . zipWith (/=) b . map (\f -> f b) |
||
statements = [ (==12) . length, |
statements = [ (==12) . length, |
||
3 ⊂ [length statements-6..], |
|||
2 ⊂ [1,3..], |
|||
4 → [4..6], |
|||
0 ⊂ [2..4], |
|||
4 ⊂ [0,2..], |
|||
1 ⊂ [1,2], |
|||
6 → [4..6], |
|||
3 ⊂ [0..5], |
|||
2 ⊂ [10,11], |
|||
1 ⊂ [6,7,8], |
|||
4 ⊂ [0..10] |
|||
] where |
] where |
||
(⊂) s x = \b -> s == (sumbool . map (b!!) . takeWhile (< length b)) x |
|||
len = length statements |
|||
(→) a x = \b -> not (b!!a) || all (b!!) x |
|||
main = let t n s = filter ((==n).fst) [(wrongness b s, b) | b <- tf s] in do |
main = let t n s = filter ((==n).fst) [(wrongness b s, b) | b <- tf s] in do |
||
Line 64: | Line 64: | ||
(1,[False,False,False,True,False,False,False,True,False,True,True,True]) |
(1,[False,False,False,True,False,False,False,True,False,True,True,True]) |
||
</pre> |
</pre> |
||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
<lang perl6>sub infix:<→> ($protasis,$apodosis) { !$protasis or $apodosis } |
<lang perl6>sub infix:<→> ($protasis,$apodosis) { !$protasis or $apodosis } |