1// compile 2 3// Copyright 2023 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. 6 7package p 8 9func f() { 10 F([]int{}, func(*int) bool { return true }) 11} 12 13func F[S []E, E any](a S, fn func(*E) bool) { 14 for _, v := range a { 15 G(a, func(e E) bool { return fn(&v) }) 16 } 17} 18 19func G[E any](s []E, f func(E) bool) int { 20 for i, v := range s { 21 if f(v) { 22 return i 23 } 24 } 25 return -1 26} 27