Files
go-koans/about_concurrency.go
Steven Degutis 95e2dcf25d concurrency
2012-03-17 12:04:10 -05:00

32 lines
621 B
Go

package go_koans
func isPrimeNumber(possiblePrime int) bool {
for underPrime := 2; underPrime < possiblePrime; underPrime++ {
if possiblePrime % underPrime == 0 {
return false
}
}
return true
}
func findPrimeNumbers(channel chan int) {
for i := 2; /* infinite loop */ ; i++ {
// your code goes here
assert(i < 100) // i is afraid of heights
}
}
func aboutConcurrency() {
ch := make(chan int)
assert(__delete_me__) // concurrency can be almost trivial
// your code goes here
assert(<-ch == 2)
assert(<-ch == 3)
assert(<-ch == 5)
assert(<-ch == 7)
assert(<-ch == 11)
}