Created
March 24, 2016 06:02
-
-
Save lon9/2cdeff20ff64fd29ca53 to your computer and use it in GitHub Desktop.
Goで配列に対してビットワイズに任意の関数を適用する関数 ref: http://qiita.com/Rompei/items/6b2425fca744977fd3f9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
v := []float64{1,1,1,1} | |
fmt.Println(v+1) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prog.go:7: invalid operation: v + 1 (mismatched types []float64 and int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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