On 6/3/07, Gosei Furuya <go.maxima at gmail.com> wrote:
>
> I would like to use flatten with outermap,
> I wrote newflatten dunction.
>
> (%i4) load("newflatten.lisp");
> (%o4) newflatten.lisp
> (%i5) nflatten([[[a,b,c],d],[e,f]],1);
> (%o5) [[a, b, c], d, e, f]
> (%i6) nflatten([[[a,b,c],d],[e,f]]); /*default level 3*/
> (%o6) [a, b, c, d, e, f]
> (%i7) nflatten([[[a,b,c],d],[e,f]],2);
> (%o7) [a, b, c, d, e, f]
> how do you think?
>
I like the idea of specifying how many levels. In particular, this means
you could give a useful error message in cases where N levels aren't
present, which will, I suspect, catch a lot of errors -- but I see from %o6
that you do not do this. I would have thought that the intuition of
nflatten was that you know a priori that the object consists precisely of
nested lists to N levels. Also, I wonder if nflatten works only for the "["
operator, or for other operators as well, and for mixed operators, e.g. sets
of lists or lists of sets. If so, is the result a list or a set?
-s