Twelve statements: Difference between revisions

→‎{{header|Haskell}}: using unicode operators. Might not be a terribly smart thing to do, those who know haskell, feel free to change it
(→‎{{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:
tf (x:xs) = map (True:) s ++ map (False:) s where s = tf xs
 
sumbool = sumlength . mapfilter fromEnumid
wrongness b = sumbool . zipWith (/=) b . map (\f -> f b)
 
statements = [ (==12) . length,
sumto 3 [lenlength statements- 6..],
sumto 2 [1,3..],
\b -> not (b!!4) || all (b!!) [5,4..6],
\b0 -> not $ any (b!!) [2..4],
sumto 4 [0,2..],
sumto 1 [1,2],
\b -> not (b!!6) || all (b!!) [4,5..6],
sumto 3 [0..5],
sumto 2 [10,11],
sumto 1 [6,7,8],
sumto 4 [0..10]
] where
(⊂) s x = \b -> s == (sumbool . map (b!!) . takeWhile (< length b)) x
len = length statements
sumto(→) sa x b = s\b ==-> (sumbool . mapnot (b!!a) .|| takeWhileall (< length b)!!) x
 
main = let t n s = filter ((==n).fst) [(wrongness b s, b) | b <- tf s] in do
Line 64:
(1,[False,False,False,True,False,False,False,True,False,True,True,True])
</pre>
 
=={{header|Perl 6}}==
<lang perl6>sub infix:<→> ($protasis,$apodosis) { !$protasis or $apodosis }
Anonymous user