Исходники и презентации
This commit is contained in:
26
lessons/functions/random_generator/main.go
Normal file
26
lessons/functions/random_generator/main.go
Normal file
@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func produce(source int, permutation func(int) int) func() int {
|
||||
return func() int {
|
||||
source = permutation(source)
|
||||
return source
|
||||
}
|
||||
}
|
||||
|
||||
func mutate(number int) int {
|
||||
return (1664525*number + 1013904223) % 2147483647
|
||||
}
|
||||
|
||||
func main() {
|
||||
next := produce(1, mutate)
|
||||
|
||||
fmt.Println(next())
|
||||
fmt.Println(next())
|
||||
fmt.Println(next())
|
||||
fmt.Println(next())
|
||||
fmt.Println(next())
|
||||
}
|
||||
Reference in New Issue
Block a user