github.com/isyscore/isc-gobase@v1.5.3-0.20231218061332-cbc7451899e9/isc/test/generic_test.go (about) 1 package test 2 3 import ( 4 "github.com/isyscore/isc-gobase/isc" 5 "testing" 6 ) 7 8 func TestGeneric(t *testing.T) { 9 list := isc.NewListWithItems(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) 10 i := list.IndexOf(5) 11 t.Logf("indexOf(5) = %d\n", i) 12 13 l2 := list.Filter(func(item int) bool { 14 return item%2 == 0 15 }) 16 17 t.Logf("filter = %v\n", l2) 18 19 lg := isc.ListToTripleFrom[int, string, string](list) 20 mg := lg.GroupBy(func(item int) string { 21 if item%2 == 0 { 22 return "even" 23 } else { 24 return "odd" 25 } 26 }) 27 t.Logf("grouped = %v\n", mg) 28 }