Skip to content

Instantly share code, notes, and snippets.

@spytheman
Created September 3, 2019 22:22
Show Gist options
  • Save spytheman/6f8cc066de44183860678d27a7e83fb0 to your computer and use it in GitHub Desktop.
Save spytheman/6f8cc066de44183860678d27a7e83fb0 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/v run
import time
fn myrand_r(seed &u32) int {
mut rs := seed
ns := u32( *rs * u32(1103515245) + u32(12345) )
*rs = ns
return int( ns & u32(0x7fffffff) )
}
s := u32( time.now().uni )
x := myrand_r( &s )
y := myrand_r( &s )
println('x: $x | y: $y')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment