when i try to get the max of the two lists it ignores the items with empty
i want an output matrix of 28 rows
Tried
I mean when i add or get the max, the matrix ignores the empty items removed
I want the output matrix to be 28 also
Thanks in advance
Can i replace it by zeros ?
as an example
not working
can i replace Empty List ? or you mean Null
Hello,
After flattening your lists.
Code Block:
a;
Count_b=DSCore.List.Count(b);
res=[];
[Imperative]
{
for (i in 0..Count_b-1)
{
if (a[i]/a[i]==1 && b[i]/b[i]==1)
{
res[i]=Math.Max(a[i],b[i]);
}
else
{
res[i]=b[i];
}
}
return res;
};
Cordially
christian.stan
List.Create > Liat.Transpose > List.MaximumItem should also do the trick. Just watch the list levels as you go along.
Works but need to be more dynamic to count the larger list items
as i am not sure that variable b will be always the longest matrix
when reversed it calculate to the short list items (a)
I am new to Dynamo & Python
Thanks in advance
not working
Thanks in advance
This is the main problem i faced
when adding a list with empty items it ignores some rows
here, a has 6 items & b has 6 items … Result shall be a list of 6 items of the maximum value of a & b
Thanks in advance
This works correctly !
Thanks alot!
I just want to get the min of the two lists also
not changing max to min as it gets the shorter list
I want the min value
Sry, I am not familiar with python
Hello, here is an adaptation (the objective is to progress, you can watch, not necessarily the most effective solution), taken into account if 2 empty items too
Code Block
a=DSCore.List.Flatten(A,1);
b=DSCore.List.Flatten(B,1);
Count_a=DSCore.List.Count(a);
Count_b=DSCore.List.Count(b);
Max_Count=Math.Max(Count_a,Count_b);
res=[];
Result=[Imperative]
{
for (i in 0..Max_Count-1)
{
if (a[i]/a[i]==1 && b[i]/b[i]==1)
{
res[i]=Math.Max(a[i],b[i]);
}
else
{
if(a[i]/a[i]==1)
{
res[i]=a[i];
}
elseif(b[i]/b[i]==1)
{
res[i]=b[i];
}
else
{
res[i]="Item a & b are empty";
}
}
}
return DSCore.List.Chop(res,1);
};
Cordially
christian.stan
Still Same problem
As here both list a & b have empty items
Need to replace all empty list with zeros if any
When we have an error, the minimum is to show the code (it’s for the min? the max ? ¯\(ツ)/¯ ) and the error message
here an alternative
Hello,
The feed in the code block had to be of the same rank
I added code block
to transform your list
and add with bool max or min possibility (added value)
code block added
a;
K=DSCore.List.Count(b);
res=[];
[Imperative]
{
for (i in 0..K-1)
{
if (b[i]==true)
{
res[i]=a[[i]];
}
else
{
res[i]=a[i];
}
}
return res;
};
modified block code with possible max min
a=DSCore.List.Flatten(A,1);
b=DSCore.List.Flatten(B,1);
Count_a=DSCore.List.Count(a);
Count_b=DSCore.List.Count(b);
Max_Count=Math.Max(Count_a,Count_b);
res=[];
c=choice==true?Math.Max:Math.Min;
//True: Max False: Min
Result=[Imperative]
{
for (i in 0..Max_Count-1)
{
if (a[i]/a[i]==1 && b[i]/b[i]==1)
{
res[i]=c(a[i],b[i]);
}
else
{
if(a[i]/a[i]==1)
{
res[i]=a[i];
}
elseif(b[i]/b[i]==1)
{
res[i]=b[i];
}
else
{
res[i]="Item a & b are empty";
}
}
}
return
{"List Long":
DSCore.List.Chop(res,1),
"List Short":
DSCore.List.Chop(res[0..Math.Min(Count_a,Count_b)-1],1)};
};
cordially
christian.stan