Skip to content

Commit

Permalink
Add simple list operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ktnlvr committed Jun 3, 2023
1 parent 67c5138 commit 4f36908
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions pystd/random.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Sequence

_seed = 0


def seed(a: int, version: int = 2):
def seed(a: int = None, version: int = 2):
global _seed
_seed = a

Expand All @@ -14,20 +16,42 @@ def setstate(state: object):
...


def randbytes(n: int) -> bytes:
def getrandbits(k) -> int:
...


def getrandbits(k) -> int:
def randbytes(n: int) -> bytes:
...


def random() -> float:
...


def uniform(a: float, b: float) -> float:
...


def randint(a: int, b: int) -> int:
assert a <= b
global _seed
_seed = (69069 * _seed + 1) % 2**32
return _seed % (b + 1 - a) + a


def choice(seq: Sequence) -> object:
...


def choices(
population, weights=None, *, cumulative_weights=None, k=1
) -> list:
...


def shuffle(seq: Sequence) -> object:
...


def sample(population, k, *, counts=None):
...

0 comments on commit 4f36908

Please sign in to comment.