Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A list, subpatterns, and mixing them

10 views
Skip to first unread message

gamo

unread,
Apr 19, 2022, 6:18:16 AM4/19/22
to

Hi there!

I have a list of attributes, say it's middle sized.

After that, I have a bunch of subpatterns of this attributes that are
coherent both internally and to concatenate to another subpatterns.

How could I structure this both teorethically and practically?

Thanks in advance, as usual.




--
http://gamo.sdf-eu.org/
perl -E 'say "Error: Total mess"'

Ben

unread,
Apr 19, 2022, 10:24:44 AM4/19/22
to
gamo <ga...@telecable.es> writes:

> I have a list of attributes, say it's middle sized.
>
> After that, I have a bunch of subpatterns of this attributes that are
> coherent both internally and to concatenate to another subpatterns.
>
> How could I structure this both teorethically and practically?

I, for one, don't know what you are asking. I think an example would
help you get better answers.

--
Ben.

RAT

unread,
Apr 20, 2022, 10:16:05 AM4/20/22
to
You're probably looking for Moose or any of the various OO methodologies in Perl.
Perhaps have a look at this: https://metacpan.org/pod/Moo

gamo

unread,
Apr 20, 2022, 1:01:50 PM4/20/22
to
El 19/4/22 a las 16:24, Ben escribió:
#!/usr/bin/perl -w

use 5.032;

my @m = 'a' .. 'f';

my @pars = qw ( ac ce bf db ee );

my $l = 7; # a squared

my $n = 4 * 4; # size



my $c =0;
my $pick;
my @square;
do {
$pick = @m[int rand(scalar @m)];
if (@square == 0 || @square != $l-1 || @square != 2*$l-1 || @square
!= 3*$l-1){
push @square, $pick;
$c++;
}else{
for (@pars){
if ($square[$c-1].$pick != $_){
push @square, $pick;
$c++;
last;
}
}
}
}until ($c == $l);


exit 2;

--
http://gamo.sdf-eu.org/
perl -E 'say "Thank you."'

Ben

unread,
Apr 20, 2022, 4:17:16 PM4/20/22
to
gamo <ga...@telecable.es> writes:

> El 19/4/22 a las 16:24, Ben escribió:
>> gamo <ga...@telecable.es> writes:
>>
>>> I have a list of attributes, say it's middle sized.
>>>
>>> After that, I have a bunch of subpatterns of this attributes that are
>>> coherent both internally and to concatenate to another subpatterns.
>>>
>>> How could I structure this both teorethically and practically?
>>
>> I, for one, don't know what you are asking. I think an example would
>> help you get better answers.
>>
>
> #!/usr/bin/perl -w
>
> use 5.032;
>
> my @m = 'a' .. 'f';
>
> my @pars = qw ( ac ce bf db ee );
>
> my $l = 7; # a squared
>
> my $n = 4 * 4; # size

No used.

> my $c =0;
> my $pick;
> my @square;
> do {
> $pick = @m[int rand(scalar @m)];

I'd put my $pick = @m[int rand(scalar @m)]; here.

> if (@square == 0 || @square != $l-1 || @square != 2*$l-1 || @square != 3*$l-1){

Let's see when this condition would not be true by inverting it using
the rule not(A or B or C) = not A and not B and not C:

@square != 0 && @square == $l-1 && @square == 2*$l-1 && @square == 3*$l-1

This condition (the "else" case) can never be true. Basically your code
makes a random list of $l letters from @m.

> push @square, $pick;
> $c++;
> }else{
> for (@pars){
> if ($square[$c-1].$pick != $_){
> push @square, $pick;
> $c++;
> last;
> }
> }
> }
> }until ($c == $l);
>
>
> exit 2;

I can't relate this code to the words in the question, and I can't work
out what it is you are trying to do. You are making helping you very
hard!

--
Ben.

gamo

unread,
Apr 20, 2022, 11:18:42 PM4/20/22
to
El 20/4/22 a las 22:17, Ben escribió:
>>> I, for one, don't know what you are asking. I think an example would
>>> help you get better answers.
>>>

I try to write a draft as you requested.


>> #!/usr/bin/perl -w
>>
>> use 5.032;
>>
>> my @m = 'a' .. 'f';
>>
>> my @pars = qw ( ac ce bf db ee );
>>
>> my $l = 7; # a squared
>>
>> my $n = 4 * 4; # size
> No used.
>
>> my $c =0;
>> my $pick;
>> my @square;
>> do {
>> $pick = @m[int rand(scalar @m)];
> I'd put my $pick = @m[int rand(scalar @m)]; here.
>
>> if (@square == 0 || @square != $l-1 || @square != 2*$l-1 || @square != 3*$l-1){

Wrong. This is a always match case.

> Let's see when this condition would not be true by inverting it using
> the rule not(A or B or C) = not A and not B and not C:
>
> @square != 0 && @square == $l-1 && @square == 2*$l-1 && @square == 3*$l-1
>

Wrong. This is a never match case.

The case is that neither redactions are correct.

What I really mean (as an example) is

@square == 0 && @square != $l-1 et cetera.

> This condition (the "else" case) can never be true. Basically your code
> makes a random list of $l letters from @m.
>
>> push @square, $pick;
>> $c++;
>> }else{
>> for (@pars){
>> if ($square[$c-1].$pick != $_){
>> push @square, $pick;
>> $c++;
>> last;
>> }
>> }
>> }
>> }until ($c == $l);
>>
>>
>> exit 2;

> I can't relate this code to the words in the question, and I can't work
> out what it is you are trying to do. You are making helping you very
> hard!


That's because what I mean in the first place is what I really want to
mean. Summary:

1) You have a pool of types of attributes
2) You have pairs of undesiderable neighbors or better, a cost function
3) You have to make subgroups of the 1) in order to get a great arrange

This is similar to the knapsack problem.
BUT there are additional problems as how many times you admit a certain
attribute or that you must check different sizes in different orders.

Not a simple problem.

Thanks, anyhow.





>
> -- Ben.


--
http://gamo.sdf-eu.org/
perl -E 'say "Error: Batteries low"'

Ben

unread,
Apr 21, 2022, 6:24:48 AM4/21/22
to
gamo <ga...@telecable.es> writes:

> El 20/4/22 a las 22:17, Ben escribió:
>>>> I, for one, don't know what you are asking. I think an example would
>>>> help you get better answers.
>>>>
>
> I try to write a draft as you requested.
>
>
>>> #!/usr/bin/perl -w
>>>
>>> use 5.032;
>>>
>>> my @m = 'a' .. 'f';
>>>
>>> my @pars = qw ( ac ce bf db ee );
>>>
>>> my $l = 7; # a squared
>>>
>>> my $n = 4 * 4; # size
>> No used.
>>
>>> my $c =0;
>>> my $pick;
>>> my @square;
>>> do {
>>> $pick = @m[int rand(scalar @m)];
>> I'd put my $pick = @m[int rand(scalar @m)]; here.
>>
>>> if (@square == 0 || @square != $l-1 || @square != 2*$l-1 || @square != 3*$l-1){
>
> Wrong. This is a always match case.

Yes, that was my point. This condition is never false.

>> Let's see when this condition would not be true by inverting it using
>> the rule not(A or B or C) = not A and not B and not C:
>> @square != 0 && @square == $l-1 && @square == 2*$l-1 && @square == 3*$l-1
>
> Wrong. This is a never match case.

I think you missed what I was saying. Of course it's wrong.

Anyway, I'm out. I hope you sorted out whatever problem it was you were
having.

--
Ben.

Rainer Weikusat

unread,
Apr 26, 2022, 3:11:15 PM4/26/22
to
Perl has a perfectly functional built-in 'OO methodology'.
0 new messages