Created
January 8, 2019 19:48
-
-
Save seemcat/54309bd1ba5860be9e64b2a5bb33c23c to your computer and use it in GitHub Desktop.
c0d3 solved in 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 ( | |
"time" | |
"fmt" | |
"sync" | |
) | |
func newFunc(b int, fn func()) func() { | |
return func() { | |
time.AfterFunc(time.Duration(b)*time.Second, fn) | |
} | |
} | |
func solution10(a, b int, fn func()) { | |
f := newFunc(b, fn) | |
time.AfterFunc(time.Duration(a)*time.Second, f) | |
} | |
func main() { | |
var wg sync.WaitGroup | |
wg.Add(2) | |
// not printing out because program exits soon as main finishes | |
fn := func() { fmt.Print("hello") } | |
solution10(1, 100, fn); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment