36 go
func identityMat4() [16]float {
return {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 }
}
Run Code Online (Sandbox Code Playgroud)
我希望你能从这个例子中了解我想要做的事情.我怎么在Go中这样做?
Set*_*nig 45
func identityMat4() [16]float64 {
return [...]float64{
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 }
}
Run Code Online (Sandbox Code Playgroud)
(点击播放)
小智 11
s := []int{5, 2, 6, 3, 1, 4} // unsorted
sort.Ints(s)
fmt.Println(s)
Run Code Online (Sandbox Code Playgroud)
如何使用数组初始值设定项来初始化测试表块:
tables := []struct {
input []string
result string
} {
{[]string{"one ", " two", " three "}, "onetwothree"},
{[]string{" three", "four ", " five "}, "threefourfive"},
}
for _, table := range tables {
result := StrTrimConcat(table.input...)
if result != table.result {
t.Errorf("Result was incorrect. Expected: %v. Got: %v. Input: %v.", table.result, result, table.input)
}
}
Run Code Online (Sandbox Code Playgroud)