diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2026-01-19 20:51:26 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2026-01-19 20:52:23 -0500 |
| commit | f905f1e4d1c77410931dc5ebfd8bcf466864a3e2 (patch) | |
| tree | 32d52ad87f303237e451c90c1a33b12217a1c6e5 /api/integers.yaml | |
| parent | a36f149d0837f4424aeda1a1853f08c27aeafa44 (diff) | |
Allow parsing `123.foo()` as `(123).foo()`
Diffstat (limited to 'api/integers.yaml')
| -rw-r--r-- | api/integers.yaml | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/api/integers.yaml b/api/integers.yaml index bbbd395d..68a66752 100644 --- a/api/integers.yaml +++ b/api/integers.yaml @@ -35,7 +35,7 @@ Int.choose: description: > The number of things to be chosen. example: | - assert (4).choose(2) == 6 + assert 4.choose(2) == 6 Int.clamped: short: clamp an integer @@ -60,7 +60,7 @@ Int.clamped: description: > The highest value the result can take. example: | - assert (2).clamped(5, 10) == 5 + assert 2.clamped(5, 10) == 5 Int.factorial: short: factorial @@ -76,7 +76,7 @@ Int.factorial: description: > The integer to compute the factorial of. example: | - assert (10).factorial() == 3628800 + assert 10.factorial() == 3628800 Int.get_bit: short: check whether a bit is set @@ -103,10 +103,10 @@ Int.get_bit: description: > The index of the bit to check (1-indexed). example: | - assert (6).get_bit(1) == no - assert (6).get_bit(2) == yes - assert (6).get_bit(3) == yes - assert (6).get_bit(4) == no + assert 6.get_bit(1) == no + assert 6.get_bit(2) == yes + assert 6.get_bit(3) == yes + assert 6.get_bit(4) == no Int.hex: short: convert to hexidecimal @@ -137,7 +137,7 @@ Int.hex: description: > Whether to include a "0x" prefix. example: | - assert (255).hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF" + assert 255.hex(digits=4, uppercase=yes, prefix=yes) == "0x00FF" Int.is_between: short: test if an int is in a range @@ -161,10 +161,10 @@ Int.is_between: description: > The other end of the range to check (inclusive). example: | - assert (7).is_between(1, 10) == yes - assert (7).is_between(10, 1) == yes - assert (7).is_between(100, 200) == no - assert (7).is_between(1, 7) == yes + assert 7.is_between(1, 10) == yes + assert 7.is_between(10, 1) == yes + assert 7.is_between(100, 200) == no + assert 7.is_between(1, 7) == yes Int.is_prime: short: check if an integer is prime @@ -190,8 +190,8 @@ Int.is_prime: description: > The number of repetitions for primality tests. example: | - assert (7).is_prime() == yes - assert (6).is_prime() == no + assert 7.is_prime() == yes + assert 6.is_prime() == no Int.next_prime: short: get the next prime @@ -212,7 +212,7 @@ Int.next_prime: description: > The integer after which to find the next prime. example: | - assert (11).next_prime() == 13 + assert 11.next_prime() == 13 Int.octal: short: convert to octal @@ -238,7 +238,7 @@ Int.octal: description: > Whether to include a "0o" prefix. example: | - assert (64).octal(digits=4, prefix=yes) == "0o0100" + assert 64.octal(digits=4, prefix=yes) == "0o0100" Int.onward: short: iterate from a number onward @@ -261,7 +261,7 @@ Int.onward: The increment step size. example: | nums : &[Int] = &[] - for i in (5).onward() + for i in 5.onward() nums.insert(i) stop if i == 10 assert nums[] == [5, 6, 7, 8, 9, 10] @@ -334,7 +334,7 @@ Int.prev_prime: description: > The integer before which to find the previous prime. example: | - assert (11).prev_prime() == 7 + assert 11.prev_prime() == 7 Int.sqrt: short: square root @@ -350,8 +350,8 @@ Int.sqrt: description: > The integer whose square root is to be calculated. example: | - assert (16).sqrt() == 4 - assert (17).sqrt() == 4 + assert 16.sqrt() == 4 + assert 17.sqrt() == 4 Int.to: short: iterate a range of integers @@ -376,14 +376,14 @@ Int.to: description: > An optional step size to use. If unspecified or `none`, the step will be inferred to be `+1` if `last >= first`, otherwise `-1`. example: | - iter := (2).to(5) + iter := 2.to(5) assert iter() == 2 assert iter() == 3 assert iter() == 4 assert iter() == 5 assert iter() == none - assert [x for x in (2).to(5)] == [2, 3, 4, 5] - assert [x for x in (5).to(2)] == [5, 4, 3, 2] - assert [x for x in (2).to(5, step=2)] == [2, 4] + assert [x for x in 2.to(5)] == [2, 3, 4, 5] + assert [x for x in 5.to(2)] == [5, 4, 3, 2] + assert [x for x in 2.to(5, step=2)] == [2, 4] |
