Skip to main content
added 205 characters in body
Source Link
Rahul Gopinath
  • 3.2k
  • 13
  • 22

perhaps?grouping list separated by some values intuitively seems like a group by operation. That is, abc,def,ghi => (abc)(def)(ghi) So groupBy seems more intuitive for me, and it results in more concise code.

import Data.List

explode fn = filter (nfn . head)) . gb
  where nfn = not . fn
        gb = groupBy ((. nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)

perhaps?

import Data.List

explode fn = filter (nfn . head)) . gb
  where nfn = not . fn
        gb = groupBy ((. nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)

grouping list separated by some values intuitively seems like a group by operation. That is, abc,def,ghi => (abc)(def)(ghi) So groupBy seems more intuitive for me, and it results in more concise code.

import Data.List

explode fn = filter (nfn . head) . gb
  where nfn = not . fn
        gb = groupBy ((. nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)
added 1 characters in body
Source Link
Rahul Gopinath
  • 3.2k
  • 13
  • 22

perhaps?

import Data.List

explode fn = filter (nfn . head)) . gb
  where nfn = not . fn
        gb = groupBy ((. nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)

perhaps?

import Data.List

explode fn = filter (nfn . head)) . gb
  where nfn = not . fn
        gb = groupBy ((.nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)

perhaps?

import Data.List

explode fn = filter (nfn . head)) . gb
  where nfn = not . fn
        gb = groupBy ((. nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)
Source Link
Rahul Gopinath
  • 3.2k
  • 13
  • 22

perhaps?

import Data.List

explode fn = filter (nfn . head)) . gb
  where nfn = not . fn
        gb = groupBy ((.nfn) . (&&) . nfn)

If you cann't tolerate pointfree, here is the alternate definition for gb

gb = groupBy (\x y -> nfn x && nfn y)