These days one would use context.Context to cancel the 2nd and 3rd place
workers. Workers would select on the send including the channel from the
cancellable Context.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this grou
A ^ normally matches either the start of string or the start of a new line
(with the m flag).
I'd like to match only starts of lines, but not starts of strings, ideally
without changing the regexp.
My source data is in a ReadSeeker, and if I use
Regexp.FindReaderSubmatchIndex() I can get the fi
I think it is, though this is a bit lawyery.
> Otherwise, when evaluating the operands of an expression, assignment,
> or return statement, all function calls, method calls, and
> communication operations are evaluated in lexical left-to-right
> order.
This does not mention type conversions, so t
Consider the following program: https://play.golang.org/p/_RjR5dCQ_KW
package main
import (
"bufio"
"strings"
"fmt"
)
const data = "short\nthisisverylonglong\n"
var in = bufio.NewScanner(strings.NewReader(data))
func next() []byte {
in.Scan()
return in.Bytes()
}
func main() {
in.B
For 64 bit word size: https://stackoverflow.com/questions/11376288/fast
-computing-of-log2-for-64-bit-integers/11398748#11398748
This can be derived from examples in https://graphics.stanford.edu/~sea
nder/bithacks.html which gives the 32 bit version.
However, the math/bits package gives you Len,
Here’s a way to do a similar thing now:
https://play.golang.org/p/CtEYUo6MuqN
func main() {
x := []int{5, 1, 4, 2, 3}
sort.Sort(ClosureSort(func() int { return (len(x)) },
func(i, j int) bool { return x[i] < x[j] },
func(i, j int) { x[i], x[j] = x[j], x[i] }))
fmt.Prin
Seven years later, I had the same idea as Js.
Before:
type intslice []int func (x intslice) Len() int { return len(x) } func (x
intslice) Less(i, j int) bool { return x[i] < x[j] } func (x intslice)
Swap(i, j int) { x[i], x[j] = x[j], x[i] } func main() { x := intslice{5,
1, 4, 2, 3} sort.Sort
Yeah I'm not a math wiz and the older I get the harder I find maths.
But sometimes you can't evade maths in programming.
So here's my question for math wizards.
Essentially, I'm trying to write an url shortener.
And I found this package I agree with (don't re-invent the wheel)
https://github.com/n
1. What are a stack and queue?
2. What does “concurrent and blocking” mean for a data structure?
3. What does accessing one var from concurrent goroutines look like?
We can answer these for you if you don't know the answer.
Matt
On Sunday, April 8, 2018 at 12:37:26 AM UTC-5, Xen wrote:
>
> Hi
That's a tough one. If your interviewer is an excellent engineer without an
ego, you may want to point out that it might be better to keep concurrency
and data structures separated. Perhaps you could even tell the story of the
deprecated Java Vector class.
If your interviewer want you to show t
10 matches
Mail list logo