• @[email protected]
    link
    fedilink
    11
    edit-2
    1 year ago
    def is_even(n):
        match n:
            case 1:
                return False
            case 0:
                return True
            # fix No1
            case n < 0:
                return is_even(-1*n)
            case _:
                return is_even(n-2)
    
    • @[email protected]
      link
      fedilink
      English
      41 year ago

      Python added match/case?! Bunch of mypy issues have been closed too. Maybe its time to dust off some old projects.

    • @Chobbes
      link
      31 year ago

      Well… At least it’s tail recursive.