How to extract boolean from list like python's all method

Hello

I want to make block like below , But I don’t know how to solve this.
Please help me.

If there are more than one True in the list ,then I want to extract True.
If there are no True in the list , then I want to extract False.

Mass Addition will treat ‘False’ as zero and ‘True’ as 1, so if the result is greater than zero (or greater than one?), the result is ‘True’. Do you really mean this?

If there are more than one True in the list ,then I want to extract True.

So if there is only one ‘True’ the result is ‘False’?

P.S. If only one is True, you can use the logical Or component:

logical_or

2 Likes

Thank you so much Joseph.

From your suggestion I made blocks this way.
this might works.

At first , I want to replace True to 1, False to 0 and calculate, but I don’t know how to replace ・・・
So I made this way.

You didn’t answer my question. And didn’t post your GH file.

logical_OR_2021_Jul7a
logical_OR_2021_Jul7a.gh (7.9 KB)

1 Like

Thank you Joseph.

will treat ‘False’ as zero and ‘True’ as 1, so if the result is greater than zero (or greater than one?) , the result is ‘True’. Do you really mean this?
yes

So if there is only one ‘True’ the result is ‘False’?
Result is True.

TrueFalse.gh (11.7 KB)

I want item(True or False) from list ,so your suggestion to use mass addition is the best way!!

I thought another 2 ways. Later one is also good.
I learned many things from this question. Thaks!


TrueFalse.gh (18.6 KB)

When there are two true, this logic have trouble
So I Changed like this.


TrueFalse.gh (21.5 KB)

I’m not following your experiments in detail but it appears to me that you don’t understand the effects of Partition and Create Set.

I’ll leave you with this, showing how Mass Multiplication of Booleans is equivalent to logical AND, just as Mass Addition of Booleans is equivalent to logical OR.

logical_ops_2021_Jul9a
logical_ops_2021_Jul9a.gh (5.9 KB)

2 Likes

Thank you Joseph.

I also don’t know Mass Multiplication
It is very useful.

I used Partition to express part real problem using tree.
Maybe you don’t need Partition, because you may understand difference between tree and list.
But I don’t know , I’m very beginner. My experience of GH is within 1 month.
So I used partition.


TrueFalse.gh (21.3 KB)

Do you have any suggestion to get these basic techniques information of GH?

I’ve already made them. Partition makes no sense to me at all in this context and may be contributing to your confusion…

Just in case you aren’t aware, you can also use Python in Grasshopper:


210711_GHPython_All_00.gh (4.8 KB)

1 Like

What a simple way!!
To tell the truth, I once tried using python but couldn’t do it.
I don’t know how to treat boolean.

A boolean is true (1) or false (0). That’s really all that is to it. :slight_smile:

1 Like

I could understand From your sample.
Thank you so much!!

  1. text parameter and object parameter
  2. List Item


210711_GHPython_All_00.gh (8.0 KB)

It looks like you are demonstrating ‘List Access’ and ‘Type hint’ = ‘bool’ in Python?
Thread title says “like python”, not “in python”. Four days… happy now?

One more time, with branches, just in case:

MA_MM_2021_Jul11b
MA_MM_2021_Jul11b.gh (11.1 KB)

1 Like

Thanks you Joseph.

At first ,I tried python script by using all, but it didn’t work.
Now I could understand why python didn’t work because I didn’t know list access and so on.

After python script failure , I also gave up by branches and write this thread.

I’m just searching Entwine. I found from your suggestion. Very good timing!!

The Python that @AndersDeleuran gave you works with branches too, equivalent to MM.

Your text panels have ‘Draw Paths’ disabled, which suppresses the branches. Why? That’s bad!

MA_MM_2021_Jul12a
MA_MM_2021_Jul12a.gh (15.0 KB)