Created
August 18, 2015 03:29
-
-
Save 178inaba/4a071cfb36da16681bbc to your computer and use it in GitHub Desktop.
matrix from go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" | |
| ) | |
| func main() { | |
| box := append(packRune('0', '9'), packRune('a', 'z')...) | |
| box = append(box, packRune('A', 'Z')...) | |
| rand.Seed(time.Now().UnixNano()) | |
| for { | |
| fmt.Print("\x1b[32m", string(box[rand.Intn(len(box))]), "\x1b[0m") | |
| time.Sleep(100 * time.Microsecond) | |
| } | |
| } | |
| func packRune(start, end rune) []rune { | |
| var box []rune | |
| r := start | |
| for r-1 != end { | |
| box = append(box, r) | |
| r++ | |
| } | |
| return box | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment