github.com/searKing/golang/go@v1.2.74/container/slice/takeuntil.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package slice 6 7 // TakeUntilFunc returns, if this slice is ordered, a slice consisting of the longest 8 // prefix of elements taken from this slice that unmatch the given predicate. 9 // Otherwise returns, if this slice is unordered, a slice consisting of a 10 // subset of elements taken from this slice that unmatch the given predicate. 11 func TakeUntilFunc(s interface{}, f func(interface{}) bool) interface{} { 12 return normalizeSlice(takeUntilFunc(Of(s), f, false), s) 13 } 14 15 // takeUntilFunc is the same as TakeUntilFunc. 16 func takeUntilFunc(s []interface{}, f func(interface{}) bool, truth bool) []interface{} { 17 return takeWhileFunc(s, f, !truth) 18 }