• sebsch@discuss.tchncs.de
    link
    fedilink
    arrow-up
    15
    ·
    edit-2
    2 months ago

    Sometimes is it worth to rethink the problem. Especially when your condition is based on set-members. Using quantor logic often simplifies the condition :

    return 
        any(x for x in X if x==condition_a) 
        or all(y for y in Y if y==condition_b) 
        and all(x for x in X if x==condition_c)
    

    I am not sure if JS has something similar, but this often helps by a lot

    • Lupec@lemm.ee
      link
      fedilink
      arrow-up
      3
      ·
      2 months ago

      I am not sure if JS has something similar, but this often helps by a lot

      It does, the some/every array methods would achieve the same results. I use them quite often myself!