ocaml: phase 6 Random module (deterministic LCG) (+4 tests, 549 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s
Linear-congruential PRNG with mutable seed (_state ref). API: init s seed the PRNG self_init () default seed (1) int bound 0 <= n < bound bool () fair coin float bound uniform in [0, bound) bits () 30 bits Stepping rule: state := (state * 1103515245 + 12345) mod 2147483647 result := |state| mod bound Same seed reproduces the same sequence. Real OCaml's Random uses Lagged Fibonacci; ours is simpler but adequate for shuffles and Monte Carlo demos in baseline programs. Random.init 42; Random.int 100 = 48 Random.init 1; Random.int 10 = 0
This commit is contained in:
@@ -407,6 +407,13 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-09 Phase 6 — Random module (LCG-based, deterministic) (+4
|
||||
tests, 549 total). Linear-congruential PRNG with mutable seed
|
||||
(`_state` ref). API: init, self_init, int, bool, float, bits.
|
||||
`int bound` returns `|state| mod bound` after stepping. Same seed
|
||||
reproduces same sequence — useful for testing shuffles and Monte
|
||||
Carlo demos. Real OCaml's Random uses Lagged Fibonacci; ours is
|
||||
simpler but adequate for baseline programs.
|
||||
- 2026-05-09 Phase 6 — Hashtbl.keys / values / bindings / remove /
|
||||
clear / reset / to_seq / to_seq_keys / to_seq_values (+4 tests, 545
|
||||
total). Two new host primitives `_hashtbl_remove` and
|
||||
|
||||
Reference in New Issue
Block a user