Assuming your ad-hoc implementation is
for i, v := range s {
if !yourPredicate(v) {
s = s[:i]
break
}
}
the usual Go style is to just write the loop. The principle is it is
easier to to learn a few basic control structures and read the
composition of them in place than it is to learn a large set of
complex control structures, which is what you do when you load your
head with takeWhile, dropWhile, span, zipWith, zipWith3, lines,
concatMap, foldr, until, mapM, etc.
On Wed, Dec 10, 2014 at 11:41 AM, Bjarki Hartjenstein Gunnarsson
wrote:
I know Go isn't Haskell but I really would prefer using takeWhile instead of
my ad-hoc
implementation (though it's pretty elegant).
Regards.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.