|
|
|
|
|
by dekhn
1335 days ago
|
|
EDIT: the version I pasted below is not what I originally typed into the site. I made several errors while copy/pasting and modifying the code to run locally without a channel. It told me I have an error ("what happens at zero") when i do: func below(n uint64, to chan uint64) {
for n; n > 0; n-- {
to <- n-1
n--
}
close(to)
}
but running that function with several test inputs produces what I expected. Note, I removed the channel (replaced with println) as that doesn't add anything to the problem.Note: I've been programming (including C and C++) for 3+ decades. I make mistakes all the time, but.... what exactly are you looking for here if my solution is not ruight? EDIT: the pasted code is also incorrect, because I didn't complete converting the for loop into a while. |
|