Skip to content

Instantly share code, notes, and snippets.

@TimToady
Created August 3, 2011 00:43
Show Gist options
  • Save TimToady/1121634 to your computer and use it in GitHub Desktop.
Save TimToady/1121634 to your computer and use it in GitHub Desktop.
sub bentley_clever($seed) {
constant $mod = 1_000_000_000;
my @state;
sub subrand() {
push @state, (my $x = (@state.shift - @state[*-24]) % $mod);
$x;
}
my @seed = ($seed % $mod, 1, (* - *) % $mod ... *)[^55];
@state = @seed[ 34, (* + 34 ) % 55 ... 0 ];
subrand() for 55 .. 219;
&subrand ... *;
}
my @sr := bentley_clever(292929);
.say for @sr[^10];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment