Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #64 #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions categories/99-problems/P46-vaibhav.pl
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,16 @@ ($input)
return and(or($input1, not($input2)), or(not($input1), $input2));
}

# Using an example to understand the working
my $A = 'true';
my $B = 'true';
my $result = and($A, or($A, not($B)));
print "$A ";
print "$B ";
say $result;

$B = 'fail';
print "$A ";
print "$B ";
say $result;

$A = 'true';
$B = 'fail';
print "$A ";
print "$B ";
say $result;

$A = 'fail';
print "$A ";
print "$B ";
say $result;
#Next we define a function which will provide us the truth table
#for any logical expression made from logic gates
#given above.

sub table(&callable) {
say "{$_.join("\t")}\t{&callable(|$_)}" for [X] [True, False] xx &callable.arity;
}

# Below here is an example to understand the workingf of above script.
vendethiel marked this conversation as resolved.
Show resolved Hide resolved

table(-> $a, $b { and($a, or($a, not($b))) });

# vim: expandtab shiftwidth=4 ft=perl6