2

I have a JSON array, each item contain a boolean list of 10 values, I need to decide for each item if it's flagged as true or false by performing AND on the first three items in boolean list.

I am looking for some "elegant" non-looping way to implement this.

Example of the json:

[
  {
  "eFcw":{
    "available":true,
    "isFcwvCalculated":false,
    "clqId":-1,
    "clqId_ASIL":-1,
    "asilFailures":4098,
    "IPB_fcwResults":{
      "FCW_withA_status":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]
      }
      }},
      {
  "eFcw":{
    "available":true,
    "isFcwvCalculated":false,
    "clqId":-1,
    "clqId_ASIL":-1,
    "asilFailures":4098,
    "IPB_fcwResults":{
      "FCW_withA_status":[false,true,false,false,false,false,false,false,false,false,false,false,false,false,false]
      }
      }}]
vinzee
  • 17,022
  • 14
  • 42
  • 60
Igal
  • 4,255
  • 12
  • 39
  • 63

1 Answers1

3

You could try using all() on a slice of your list of booleans:

all(list_of_bools[:3])
aaossa
  • 3,468
  • 2
  • 19
  • 33