Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Matching elements inside two array

by ameezys (Acolyte)
on Apr 11, 2019 at 02:12 UTC ( #1232433=note: print w/replies, xml ) Need Help??


in reply to Re^2: Matching elements inside two array
in thread Matching elements inside two array

Matches meaning that the any of the data for input A and input B is listed in the input array. So the listed data is the data that I want to store value of CC0 and CC1.
  • Comment on Re^3: Matching elements inside two array

Replies are listed 'Best First'.
Re^4: Matching elements inside two array
by Marshall (Abbot) on Apr 12, 2019 at 15:03 UTC
    I am curious as to what these values represent in "real life". Looks like perhaps some sort of a HW gate?
    Why the differentiation between inputs A and B?

    I suppose:
    If an input_array token (like N3) is in both A and B, then: CC0=1 and CC1 =1.
    If an input_array token is in A but not in B, then "only 1 input is PI".
    If an input_array token is not in A regardless whether it is in B or not, then: "this is a wire".

    Looks odd to me...Is this logic correct? Is the case where input_array token is in B but not in A important? obviously in A but not in B is a special case.

Re^4: Matching elements inside two array
by Aldebaran (Deacon) on Apr 11, 2019 at 20:20 UTC

    Is any of Athananius' source helpful? Does it capture any of the logic you seek?

    $ ./1.amee.pl N1: only 1 input is PI N2: this is a wire N6: this is a wire N7: this is a wire CC0[N3] = 1 CC1[N3] = 1 $ cat 1.amee.pl #!/usr/bin/perl use 5.016; use strict; use warnings; use List::Util qw( any ); my @input_array = qw( N1 N2 N3 N6 N7 ); my @input_A = qw( N1 N3 N11 N11 N10 N16 ); my @input_B = qw( N3 N6 N2 N7 N16 N19 ); my %primaryCC0; for my $inputKey (@input_array) { if (any { $_ eq $inputKey } @input_A) { if (any { $_ eq $inputKey } @input_B) { @{ $primaryCC0{$inputKey} } = (1, 1); } else { print "$inputKey: only 1 input is PI\n"; } } else { print "$inputKey: this is a wire\n"; } } for my $key (sort keys %primaryCC0) { my ($CC0, $CC1) = @{ $primaryCC0{$key} }; print "CC0[$key] = $CC0\n"; print "CC1[$key] = $CC1\n"; } __END__ $

    What I find confusing about this script is non-descriptive output. For example, there is nothing in this problem that has anything to do with PI.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1232433]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2020-07-12 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?