On Fri 17 Apr, Dave Tweed wrote:
> On Thu, 16 Apr 1998, S. Alexander Jacobson wrote:
>
> > All that being said, we can say that there are certain properties that
> > all haskell functions must fulfill. For example a recursive function
> > should never call itself with the arguments that it recieved.
> >
> > e.g. myFunction 2 3 should not make a recursive call to myFunction 2 3
>
> You can't even say that, since things like
>
> cycle :: [a] -> [a]
> cycle xs = xs ++ cycle xs
>
> are very useful in a lazy functional language since only the portion of
> the list that is actually used in the computation will be constructed.
> (eg take 20 (cycle " ") to get a string of 20 spaces.)
> So you could say `a recursive function should not call itself on the
> right-hand side with exactly the same arguments on the left hand side as
> the argument of an operator/function is strict',
But surely in this instance (and just about every other similar example
I can think of) it would be better to write something like..
cycle xs = let circle = xs ++ circle
in circle
..thereby creating a cyclic data structure instead of a truely infinite one.
Can anybody give me an example where you couldn't use this trick?
If not, I think I must agree with S. Alexander Jacobson
Regards
--
Adrian Hey