FAQ
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.

Search Discussions

  • David Crawshaw at Dec 10, 2014 at 4:48 pm
    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.
  • Bjarki Hartjenstein Gunnarsson at Dec 10, 2014 at 6:14 pm
    I see, I'll just continue using my old implementation (you were right about
    how it was implemented)
    On Wednesday, December 10, 2014 4:48:55 PM UTC, David Crawshaw wrote:

    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
    <bjar...@gmail.com <javascript:>> 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...@googlegroups.com <javascript:>.
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 10, '14 at 4:41p
activeDec 10, '14 at 6:14p
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase