Skip to content

Commit

Permalink
Merge pull request #10 from RzywyJaszczomp/master
Browse files Browse the repository at this point in the history
Added max and min functions to the parser
  • Loading branch information
fionafibration authored May 18, 2023
2 parents cba5e3a + 569821d commit 876607b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ lcm(7, 4d20): LCM of 7 and 4d20
floor(2d6 / 2): Floor of 2d6 / 2
ceil(2d6 / 2): Ceiling of 2d6 / 2
prime(2d6): 1 if 2d6 is prime else 0
max(2d6, ... ,3d4): returns biggest result
min(2d6, ... ,3d4): returns smallest result
```
Other functions may be added.
##### Note about exponentiation:
Expand Down
2 changes: 1 addition & 1 deletion rolldice/rolldice.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def rabin_miller(p):
return True


DEFAULT_FUNCTIONS = {"abs": abs, 'gcd': gcd, 'lcm': lcm, 'ceil': math.ceil, 'floor': math.floor, 'prime': rabin_miller}
DEFAULT_FUNCTIONS = {"abs": abs, 'gcd': gcd, 'lcm': lcm, 'ceil': math.ceil, 'floor': math.floor, 'prime': rabin_miller, 'max': max, 'min': min}

DEFAULT_OPS = {ast.Add: operator.add, ast.Sub: operator.sub, ast.Mult: operator.mul,
ast.Div: operator.truediv, ast.FloorDiv: operator.floordiv,
Expand Down

0 comments on commit 876607b

Please sign in to comment.