[Haskell-beginners] Re: folds again -- myCycle
Will Ness
will_n48 at yahoo.com
Wed Mar 18 14:43:58 EDT 2009
Daniel Fischer <daniel.is.fischer <at> web.de> writes:
>
> Am Mittwoch, 18. Maerz 2009 16:14 schrieb Will Ness:
> >
> > sum $ take m $ cycle [1..k]
> > | n > 0 = x*n+y
> > where
> > (n,r) = quotRem m k
> > x = sum [1..k]
> > y = sum [1..r]
In fact, the super-brilliant deducting compiler would make it
sum $ take m $ cycle [1..k]
| n > 0 = x*n+y
where
(n,r) = quotRem m k
x = k*(k+1)/2
y = r*(r+1)/2
:) :)
Now THAT would be a deductive power to behold!
More information about the Beginners
mailing list