On 29 February 2016 at 20:24, Apostolis Xekoukoulotakis
<
apostolis.xe...@gmail.com> wrote:
> Any algebraic data type that has only one self recursion should be
> transformed into an array. Let me explain why.
> First of all, each such type would consume the same amount of memory, that
> is the union of its the memory of each constructor except its
> self-recursion.
> An array of n elements means that we have a self-recursion for n-1 elements
> and not for the last one.
>
> The fact that we have only one self-recursion allows us to have only one
> path that would generate an n-array, thus the variable n determines 1-1 the
> path that was taken, helping in performing pattern matching.
While this might make sense for unique lists, it's not an optimisation
in general, because it makes it harder for lists to share tails.
--
William Leslie
Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law. You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in. Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.