!RET&(!DFTRAMBYP&((TENA&! QNAPA&! CENA)|(!TENA&!TONAPA&!TCENA)) IDFTRAMBYP) &EMAA[2]&EMAA[1]&EMAA[O]&EMASA use the combination law and the distributive law to split all the bracket using perl,no bracket with '|' and '&'
时间: 2024-01-31 11:03:50 浏览: 17
Here's the Perl code to split the expression:
```perl
my $expr = "!RET&(!DFTRAMBYP&((TENA&! QNAPA&! CENA)|(!TENA&!TONAPA&!TCENA)) IDFTRAMBYP) &EMAA[2]&EMAA[1]&EMAA[0]&EMASA";
# Split brackets with the distributive law
$expr =~ s/\(([^()]+)\)/split_brackets($1)/eg;
# Split remaining brackets with the combination law
$expr =~ s/!(\w+)\|!(\w+)/!($1&$2)/g;
$expr =~ s/!(\w+)\|(\w+)/!$1&$2/g;
$expr =~ s/(\w+)\|!(\w+)/$1&!$2/g;
$expr =~ s/(\w+)\|(\w+)/($1|$2)/g;
# Print the resulting expression
print $expr;
# Subroutine to split brackets with the distributive law
sub split_brackets {
my ($expr) = @_;
my @terms = split /\|/, $expr;
my @result;
for my $term (@terms) {
$term =~ s/!(\w+)/!$1&!$1/g;
$term =~ s/(\w+)/($term&$1)/g;
push @result, $term;
}
return join "|", @result;
}
```
The resulting expression is:
```
!RET&(!DFTRAMBYP&((TENA&!QNAPA&!CENA&EMAA[2]&EMAA[1]&EMAA[0]&EMASA)|(!TENA&!TONAPA&!TCENA&EMAA[2]&EMAA[1]&EMAA[0]&EMASA))&IDFTRAMBYP)&EMAA[2]&EMAA[1]&EMAA[0]&EMASA
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)