@@ -617,19 +617,19 @@ take(Count, List) ->
617617% % avoiding any delegation through seq.erl (which would cause circular recursion).
618618% %
619619% % Calling convention: Randomizer is fun(ok) -> float() (F# unit -> float curried).
620- % % Random (System.Random) is the atom ok; all randomness goes through fable_random .
620+ % % Random (System.Random) is a reference() holding per-instance PRNG state .
621621
622622- spec random_shuffle_by (fun ((ok ) -> float ()), list ()) -> list ().
623623random_shuffle_by (Randomizer , Xs ) ->
624624 shuffle_loop (Randomizer , erlang :list_to_tuple (Xs ), erlang :length (Xs ) - 1 ).
625625
626- - spec random_shuffle_with (ok , list ()) -> list ().
627- random_shuffle_with (_Random , Xs ) ->
628- random_shuffle_by (fun (_ ) -> fable_random :next_double () end , Xs ).
626+ - spec random_shuffle_with (reference () , list ()) -> list ().
627+ random_shuffle_with (Random , Xs ) ->
628+ random_shuffle_by (fun (_ ) -> fable_random :next_double (Random ) end , Xs ).
629629
630630- spec random_shuffle (list ()) -> list ().
631631random_shuffle (Xs ) ->
632- random_shuffle_with (ok , Xs ).
632+ random_shuffle_with (fable_random : new () , Xs ).
633633
634634- spec random_choice_by (fun ((ok ) -> float ()), list ()) -> term ().
635635random_choice_by (_Randomizer , []) ->
@@ -644,13 +644,13 @@ random_choice_by(Randomizer, Xs) ->
644644 lists :nth (erlang :trunc (R * Len ) + 1 , Xs )
645645 end .
646646
647- - spec random_choice_with (ok , list ()) -> term ().
648- random_choice_with (_Random , Xs ) ->
649- random_choice_by (fun (_ ) -> fable_random :next_double () end , Xs ).
647+ - spec random_choice_with (reference () , list ()) -> term ().
648+ random_choice_with (Random , Xs ) ->
649+ random_choice_by (fun (_ ) -> fable_random :next_double (Random ) end , Xs ).
650650
651651- spec random_choice (list ()) -> term ().
652652random_choice (Xs ) ->
653- random_choice_with (ok , Xs ).
653+ random_choice_with (fable_random : new () , Xs ).
654654
655655- spec random_choices_by (fun ((ok ) -> float ()), non_neg_integer (), list ()) -> list ().
656656random_choices_by (Randomizer , Count , Xs ) ->
@@ -678,13 +678,13 @@ choices_loop(Randomizer, Arr, Len, N, Acc) ->
678678 choices_loop (Randomizer , Arr , Len , N - 1 , [E | Acc ])
679679 end .
680680
681- - spec random_choices_with (ok , non_neg_integer (), list ()) -> list ().
682- random_choices_with (_Random , Count , Xs ) ->
683- random_choices_by (fun (_ ) -> fable_random :next_double () end , Count , Xs ).
681+ - spec random_choices_with (reference () , non_neg_integer (), list ()) -> list ().
682+ random_choices_with (Random , Count , Xs ) ->
683+ random_choices_by (fun (_ ) -> fable_random :next_double (Random ) end , Count , Xs ).
684684
685685- spec random_choices (non_neg_integer (), list ()) -> list ().
686686random_choices (Count , Xs ) ->
687- random_choices_with (ok , Count , Xs ).
687+ random_choices_with (fable_random : new () , Count , Xs ).
688688
689689- spec random_sample_by (fun ((ok ) -> float ()), non_neg_integer (), list ()) -> list ().
690690random_sample_by (Randomizer , Count , Xs ) ->
@@ -703,13 +703,13 @@ random_sample_by(Randomizer, Count, Xs) ->
703703 end
704704 end .
705705
706- - spec random_sample_with (ok , non_neg_integer (), list ()) -> list ().
707- random_sample_with (_Random , Count , Xs ) ->
708- random_sample_by (fun (_ ) -> fable_random :next_double () end , Count , Xs ).
706+ - spec random_sample_with (reference () , non_neg_integer (), list ()) -> list ().
707+ random_sample_with (Random , Count , Xs ) ->
708+ random_sample_by (fun (_ ) -> fable_random :next_double (Random ) end , Count , Xs ).
709709
710710- spec random_sample (non_neg_integer (), list ()) -> list ().
711711random_sample (Count , Xs ) ->
712- random_sample_with (ok , Count , Xs ).
712+ random_sample_with (fable_random : new () , Count , Xs ).
713713
714714% % Partial Fisher-Yates: after Count swaps the first Count positions hold the sample.
715715sample_loop (_Randomizer , Arr , _Len , Count , I ) when I >= Count ->
0 commit comments