1 // $G $D/$F.go && $L $F.$A && ./$A.out
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
12 for i
:= 0; i
< len(a
); i
++ {
15 println("want", a
[i
], "got", n
, "at", i
)
40 // Accumulator generator
41 func accum(n
int) func(int) int {
42 return func(i
int) int {
48 func g(a
, b
func(int) int) {
77 func newfunc() func(int) int { return func(x
int) int { return x
} }
82 check([]int{1, 4, 5, 4})
87 check([]int{2, 4, 6, 9})
90 check([]int{100, 200, 101, 201, 500, 101, 201, 500})
92 x
, y
:= newfunc(), newfunc()
94 println("newfunc returned same func")
97 if x(1) != 1 ||
y(2) != 2 {
98 println("newfunc returned broken funcs")