Skip to content

Instantly share code, notes, and snippets.

@lon9
Created March 24, 2016 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lon9/2cdeff20ff64fd29ca53 to your computer and use it in GitHub Desktop.
Save lon9/2cdeff20ff64fd29ca53 to your computer and use it in GitHub Desktop.
Goで配列に対してビットワイズに任意の関数を適用する関数 ref: http://qiita.com/Rompei/items/6b2425fca744977fd3f9
package main
import "fmt"
func main() {
v := []float64{1,1,1,1}
fmt.Println(v+1)
}
prog.go:7: invalid operation: v + 1 (mismatched types []float64 and int)
func BroadcastFunc(v []float64, f func(float64, ...interface{}) float64, args ...interface{}){
for i,_ := range v{
v[i] = f(v[i], args...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment