ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Problems.P48

Description

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P48.

Synopsis

Documentation

tablen :: Int -> ([Bool] -> Bool) -> [[Bool]] Source #

Truth tables for logical expressions with an arbitrary number of variables.

Generalize table in a way that the logical expression may contain any number of logical variables. Define tablen such that tablen n f prints the truth table for the expression f, which contains n logical variables.

Examples

>>> printTablen $ tablen 3 (\[a,b,c] -> a `and'` (b `or'` c) `equ'` a `and'` b `or'` a `and'` c)
False False False False
False False True  False
False True  False False
False True  True  True
True  False False False
True  False True  True
True  True  False False
True  True  True  True