question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

partition :: (a -> Boolean) -> Array a -> Pair (Array a) (Array a)

See original GitHub issue

Haskell provides partition in Data.List, but it’s just one of many partition functions. Can we generalize? The first step might be to accept any Foldable:

partition :: Foldable f => (a -> Boolean) -> f a -> Pair (Array a) (Array a)

Could we go one step further by parameterizing Array in the return type? Would adding a Monoid constraint to f be sufficient?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
davidchamberscommented, Apr 18, 2017

I was imagining something like this:

> S.partition(S.odd, [1, 2, 3])
[[1, 3], [2]]

> S.partition(S.odd, Cons(1, Cons(2, Cons(3, Nil))))
[Cons(1, Cons(3, Nil)), Cons(2, Nil)]

Does this seem reasonable?

0reactions
gabejohnsoncommented, Apr 19, 2017

Ahhh…we want tagBy to be exclusive.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Three way partitioning of an array around a given range
Given an array and a range [lowVal, highVal], partition the array around the range such that array is divided in three parts.
Read more >
Data.Array - purescript-arrays - Pursuit
Partition an array using a predicate function, creating a set of new arrays. One for the values satisfying the predicate function and one...
Read more >
partition - Kotlin Programming Language
Splits the original array into pair of lists, where first list contains elements for which predicate yielded true , while second list contains...
Read more >
Divide 2n array in n group in Java [closed] - Stack Overflow
Given an array of even length, and a pairwise validity test, I must partition the array elements into pairs that each pass the...
Read more >
Determine whether an array can be divided into pairs with a ...
Explanation: Array can be divided into pairs {(2, 4), (9, 3), (1, 5)} where the sum of elements in each pair is divisible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found