Left-fold product.
(*args: ArithRef)
| 1691 | |
| 1692 | |
| 1693 | def Product(*args: ArithRef) -> ArithRef: |
| 1694 | """Left-fold product.""" |
| 1695 | flat: list[ArithRef] = [] |
| 1696 | for a in args: |
| 1697 | if isinstance(a, (list, tuple)): |
| 1698 | flat.extend(a) |
| 1699 | else: |
| 1700 | flat.append(a) |
| 1701 | if not flat: |
| 1702 | return IntVal(1) |
| 1703 | result = flat[0] |
| 1704 | for a in flat[1:]: |
| 1705 | result = result * a |
| 1706 | return result |
| 1707 | |
| 1708 | |
| 1709 | # --------------------------------------------------------------------------- |