[go-nuts] Re: Small complete examples which show the power of Go?

2016-08-15 Thread anupam . kapoor
, | I always liked Rob Pike's concurrent prime seive: | https://play.golang.org/p/9U22NfrXeq ` i think what you are looking for is an elegant paper by doug-mcllroy called "squinting at power series" which bring the power of channels etc to stream processing... -- kind regards anupam --

[go-nuts] Re: Small complete examples which show the power of Go?

2016-08-10 Thread Val
Iterations over slices, maps, channels are very cool, usually straight to the point : func main() { for _, a := range []int{6, 4} { for _, b := range []int{2, 3} { for fname, f := range map[string]func(int, int) int{ "plus": func(x, y int) int { return x

[go-nuts] Re: Small complete examples which show the power of Go?

2016-08-10 Thread sphilippov
Easy parallelization and concurrency: package main import ( "runtime" ) func FoldParallel(data []float64, initialValue float64, op func(float64, float64) float64) float64 { sliceSize := len(data) / runtime.NumCPU() results := make(chan float64, runtime.NumCPU()) numResults