[Haskell-beginners] foldr with short circuit and accumulator
cwyang at aranetworks.com
Wed Feb 3 00:53:13 UTC 2016
Thank you for introducing mind-blowing ssfold, which has step function
with three argument:
> ssfold p f a0 xs = foldr (\x xs a -> if p a then a else xs (f a x)) id xs a0
Having spent last night, I've yet to got it. What a slow person!
2016-02-02 18:03 GMT+09:00 KwangYul Seo <kwangyul.seo at gmail.com>:
> Implementing a short-circuiting fold was already discussed in the
> haskell-cafe mailing list.
> On Tue, Feb 2, 2016 at 4:15 PM, Chul-Woong Yang <cwyang at aranetworks.com>
>> 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.
>> Beginners mailing list
>> Beginners at haskell.org
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners