Fwd: rolling span and groupBy for lists

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: rolling span and groupBy for lists

Harendra Kumar
Hi,


I am looking for the decision making authority or a place where questions about haskell libraries like in the email below can be asked or answered. ghc-devs told me that their list is not the right place for this and redirected me to haskell-cafe or [hidden email]. I tried sending an email to [hidden email] but that seems to be a closed list, my email got rejected, so that also does not seem like the right place. Is haskell cafe the right place? I was under the impression that haskell-cafe is for general discussions and not an owner of any of the libraries or any other haskell code. Are there any other mailing lists that I am missing? I can raise a ticket at ghc trac but I guess that cannot be the primary way to ask simple questions.

-harendra

---------- Forwarded message ----------
From: <[hidden email]>
Date: 5 February 2018 at 09:34
Subject: Re: rolling span and groupBy for lists
To: [hidden email]


You are not allowed to post to this mailing list, and your message has
been automatically rejected.  If you think that your messages are
being rejected in error, contact the mailing list owner at
[hidden email].



---------- Forwarded message ----------
From: Harendra Kumar <[hidden email]>
To: David Feuer <[hidden email]>, libraries <[hidden email]>
Cc: [hidden email]
Bcc: 
Date: Mon, 5 Feb 2018 10:07:55 +0530
Subject: Re: rolling span and groupBy for lists
I was mainly asking if it makes sense to include these functions in base/Data.List. Since the base package is maintained and ships along with ghc, and the issues are also raised at ghc trac I thought this is the right list. I am copying to [hidden email] as well. 

-harendra

On 5 February 2018 at 09:53, David Feuer <[hidden email]> wrote:
This is the wrong list. You probably meant to email haskell-cafe or perhaps [hidden email].



David Feuer
Well-Typed, LLP

-------- Original message --------
From: Harendra Kumar <[hidden email]>
Date: 2/4/18 10:50 PM (GMT-05:00)
Subject: rolling span and groupBy for lists

Hi,

For a small problem, I was looking for a groupBy like function that groups
based on a predicate on successive elements but I could not find one. I
wrote these little functions for that purpose:

-- | Like span, but with a predicate that compares two successive elements.
The
-- span ends when the two successive elements do not satisfy the predicate.
rollingSpan :: (a -> a -> Bool) -> [a] -> ([a], [a])
rollingSpan _ xs@[] = (xs, xs)
rollingSpan _ xs@[_] = (xs, [])
rollingSpan p (x1:xs@(x2:_))
    | p x1 x2 =
        let (ys, zs) = rollingSpan p xs
        in (x1 : ys, zs)
    | otherwise = ([x1], xs)

-- | Like 'groupBy' but with a predicate that compares two successive
elements.
-- A group ends when two successive elements do not satisfy the predicate.
rollingGroupBy :: (a -> a -> Bool) -> [a] -> [[a]]
rollingGroupBy _ [] = []
rollingGroupBy cmp xs =
    let (ys, zs) = rollingSpan cmp xs
    in ys : rollingGroupBy cmp zs

Are there any existing functions that serve this purpose or is there any
simpler way to achieve such functionality? If not, where is the right place
for these, if any. Can they be included in Data.List in base?

Thanks,
Harendra




_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: rolling span and groupBy for lists

Markus Läll-2
Hi Harendra -- I think you just need to register to [hidden email] to post there.

On Mon, Feb 5, 2018 at 6:02 AM, Harendra Kumar <[hidden email]> wrote:
Hi,


I am looking for the decision making authority or a place where questions about haskell libraries like in the email below can be asked or answered. ghc-devs told me that their list is not the right place for this and redirected me to haskell-cafe or [hidden email]. I tried sending an email to [hidden email] but that seems to be a closed list, my email got rejected, so that also does not seem like the right place. Is haskell cafe the right place? I was under the impression that haskell-cafe is for general discussions and not an owner of any of the libraries or any other haskell code. Are there any other mailing lists that I am missing? I can raise a ticket at ghc trac but I guess that cannot be the primary way to ask simple questions.

-harendra

---------- Forwarded message ----------
From: <[hidden email]>
Date: 5 February 2018 at 09:34
Subject: Re: rolling span and groupBy for lists
To: [hidden email]


You are not allowed to post to this mailing list, and your message has
been automatically rejected.  If you think that your messages are
being rejected in error, contact the mailing list owner at
[hidden email].




---------- Forwarded message ----------
From: Harendra Kumar <[hidden email]>
To: David Feuer <[hidden email]>, libraries <[hidden email]>
Cc: [hidden email]
Bcc: 
Date: Mon, 5 Feb 2018 10:07:55 +0530
Subject: Re: rolling span and groupBy for lists
I was mainly asking if it makes sense to include these functions in base/Data.List. Since the base package is maintained and ships along with ghc, and the issues are also raised at ghc trac I thought this is the right list. I am copying to [hidden email] as well. 

-harendra

On 5 February 2018 at 09:53, David Feuer <[hidden email]> wrote:
This is the wrong list. You probably meant to email haskell-cafe or perhaps [hidden email].



David Feuer
Well-Typed, LLP

-------- Original message --------
From: Harendra Kumar <[hidden email]>
Date: 2/4/18 10:50 PM (GMT-05:00)
Subject: rolling span and groupBy for lists

Hi,

For a small problem, I was looking for a groupBy like function that groups
based on a predicate on successive elements but I could not find one. I
wrote these little functions for that purpose:

-- | Like span, but with a predicate that compares two successive elements.
The
-- span ends when the two successive elements do not satisfy the predicate.
rollingSpan :: (a -> a -> Bool) -> [a] -> ([a], [a])
rollingSpan _ xs@[] = (xs, xs)
rollingSpan _ xs@[_] = (xs, [])
rollingSpan p (x1:xs@(x2:_))
    | p x1 x2 =
        let (ys, zs) = rollingSpan p xs
        in (x1 : ys, zs)
    | otherwise = ([x1], xs)

-- | Like 'groupBy' but with a predicate that compares two successive
elements.
-- A group ends when two successive elements do not satisfy the predicate.
rollingGroupBy :: (a -> a -> Bool) -> [a] -> [[a]]
rollingGroupBy _ [] = []
rollingGroupBy cmp xs =
    let (ys, zs) = rollingSpan cmp xs
    in ys : rollingGroupBy cmp zs

Are there any existing functions that serve this purpose or is there any
simpler way to achieve such functionality? If not, where is the right place
for these, if any. Can they be included in Data.List in base?

Thanks,
Harendra




_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.



--
Markus Läll

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: rolling span and groupBy for lists

Harendra Kumar
I guessed so and subscribed, CCing again to the libraries list, hoping it will work this time. I think instead of saying "You are not allowed to post to this mailing list" the message should say "You need to subscribe to post to this list" and it can provide info about how to subscribe as well. Is it too problematic (spam?) if these lists are open to all?

-harendra

On 5 February 2018 at 12:05, Markus Läll <[hidden email]> wrote:
Hi Harendra -- I think you just need to register to [hidden email] to post there.

On Mon, Feb 5, 2018 at 6:02 AM, Harendra Kumar <[hidden email]> wrote:
Hi,


I am looking for the decision making authority or a place where questions about haskell libraries like in the email below can be asked or answered. ghc-devs told me that their list is not the right place for this and redirected me to haskell-cafe or [hidden email]. I tried sending an email to [hidden email] but that seems to be a closed list, my email got rejected, so that also does not seem like the right place. Is haskell cafe the right place? I was under the impression that haskell-cafe is for general discussions and not an owner of any of the libraries or any other haskell code. Are there any other mailing lists that I am missing? I can raise a ticket at ghc trac but I guess that cannot be the primary way to ask simple questions.

-harendra

---------- Forwarded message ----------
From: <[hidden email]>
Date: 5 February 2018 at 09:34
Subject: Re: rolling span and groupBy for lists
To: [hidden email]


You are not allowed to post to this mailing list, and your message has
been automatically rejected.  If you think that your messages are
being rejected in error, contact the mailing list owner at
[hidden email].




---------- Forwarded message ----------
From: Harendra Kumar <[hidden email]>
To: David Feuer <[hidden email]>, libraries <[hidden email]>
Cc: [hidden email]
Bcc: 
Date: Mon, 5 Feb 2018 10:07:55 +0530
Subject: Re: rolling span and groupBy for lists
I was mainly asking if it makes sense to include these functions in base/Data.List. Since the base package is maintained and ships along with ghc, and the issues are also raised at ghc trac I thought this is the right list. I am copying to [hidden email] as well. 

-harendra

On 5 February 2018 at 09:53, David Feuer <[hidden email]> wrote:
This is the wrong list. You probably meant to email haskell-cafe or perhaps [hidden email].



David Feuer
Well-Typed, LLP

-------- Original message --------
From: Harendra Kumar <[hidden email]>
Date: 2/4/18 10:50 PM (GMT-05:00)
Subject: rolling span and groupBy for lists

Hi,

For a small problem, I was looking for a groupBy like function that groups
based on a predicate on successive elements but I could not find one. I
wrote these little functions for that purpose:

-- | Like span, but with a predicate that compares two successive elements.
The
-- span ends when the two successive elements do not satisfy the predicate.
rollingSpan :: (a -> a -> Bool) -> [a] -> ([a], [a])
rollingSpan _ xs@[] = (xs, xs)
rollingSpan _ xs@[_] = (xs, [])
rollingSpan p (x1:xs@(x2:_))
    | p x1 x2 =
        let (ys, zs) = rollingSpan p xs
        in (x1 : ys, zs)
    | otherwise = ([x1], xs)

-- | Like 'groupBy' but with a predicate that compares two successive
elements.
-- A group ends when two successive elements do not satisfy the predicate.
rollingGroupBy :: (a -> a -> Bool) -> [a] -> [[a]]
rollingGroupBy _ [] = []
rollingGroupBy cmp xs =
    let (ys, zs) = rollingSpan cmp xs
    in ys : rollingGroupBy cmp zs

Are there any existing functions that serve this purpose or is there any
simpler way to achieve such functionality? If not, where is the right place
for these, if any. Can they be included in Data.List in base?

Thanks,
Harendra




_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.



--
Markus Läll


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.