Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. foldr with short circuit and accumulator (Chul-Woong Yang)
2. Re: foldr with short circuit and accumulator
(Theodore Lief Gannon)
3. Re: foldr with short circuit and accumulator (KwangYul Seo)
----------------------------------------------------------------------
Message: 1
Date: Tue, 2 Feb 2016 16:15:47 +0900
From: Chul-Woong Yang <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] foldr with short circuit and accumulator
Message-ID:
<CALmycjqpU1Puoo=lsc_t_zunhed7+u1xh-bg_xz8hckcnjt...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Hi, all.
Can it be possible to do fold with short circuit and accumulator both?
For example, can we find an element which is same value to adjacent one?
findAdjacent [1,2..n, n, n+1, n+2.......] => n
\__very long__/
Though there can be many ways to do it, Can we do it with fold[r|l]?
I'll be happy to receive any comments.
Chul-Woong
------------------------------
Message: 2
Date: Tue, 2 Feb 2016 00:47:02 -0800
From: Theodore Lief Gannon <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] foldr with short circuit and
accumulator
Message-ID:
<cajopsucnyq-rzym5-xiis2spj0w1kandv6vdcwtvxnwdd1d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
If you mean is there any f and z for which this can be done with only
"foldr f z xs", I believe the answer is no. If you don't mind extra parts,
though:
findAdjacent :: (Eq a) => [a] -> Maybe a
findAdjacent xs = foldr f Nothing $ zip xs ps
where
ps = zipWith (==) (tail xs) xs
f (x,p) next = if p then Just x else next
On Mon, Feb 1, 2016 at 11:15 PM, Chul-Woong Yang <[email protected]>
wrote:
> Hi, all.
>
> Can it be possible to do fold with short circuit and accumulator both?
> For example, can we find an element which is same value to adjacent one?
>
> findAdjacent [1,2..n, n, n+1, n+2.......] => n
> \__very long__/
>
> Though there can be many ways to do it, Can we do it with fold[r|l]?
>
> I'll be happy to receive any comments.
>
> Chul-Woong
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20160202/26136509/attachment-0001.html>
------------------------------
Message: 3
Date: Tue, 2 Feb 2016 18:03:00 +0900
From: KwangYul Seo <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] foldr with short circuit and
accumulator
Message-ID:
<caclrxywqr439zc0mmnhc7+p9q6s9qkmr8pazebohysw_zf-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi,
Implementing a short-circuiting fold was already discussed in the
haskell-cafe mailing list.
https://mail.haskell.org/pipermail/haskell-cafe/2007-April/024171.html
On Tue, Feb 2, 2016 at 4:15 PM, Chul-Woong Yang <[email protected]>
wrote:
> Hi, all.
>
> Can it be possible to do fold with short circuit and accumulator both?
> For example, can we find an element which is same value to adjacent one?
>
> findAdjacent [1,2..n, n, n+1, n+2.......] => n
> \__very long__/
>
> Though there can be many ways to do it, Can we do it with fold[r|l]?
>
> I'll be happy to receive any comments.
>
> Chul-Woong
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20160202/ac929659/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 92, Issue 3
****************************************