kolasu icon indicating copy to clipboard operation
kolasu copied to clipboard

Reimplement Node.transform(operation: (Node) -> Node, inPlace: Boolean): Node

Open matozoid opened this issue 6 years ago • 4 comments

There's a TODO there.

matozoid avatar Jan 09 '20 19:01 matozoid

Here's what I think right now: mapTree -> should be named mapChildren transformTree -> should be named transformChildren transform -> transforms the whole tree. Can become the new transformTree and mapTree by calling transformChildren and mapChildren recursively.

That would also solve #32

matozoid avatar Jan 15 '20 20:01 matozoid

what do we mean by children and what by tree? Does "children" refers only to the direct children, while "tree" refers to the whole sub tree? So for example:

A -> B -> D
        C  -> E
             -> F

Where A contains B and C, D contains B, and C contains E and F.

In this scenario mapChildren/transformChildren, when called on A will touch only B and C, but not D, E, F. Transform instead will operate on a tree and therefore when called on "A" will touch A, B,C,D,E, and F. When called on C, it will touch C, E, and F.

Is that correct? If this is the case I would call transform "transformTree", to avoid ambiguity

ftomassetti avatar Jan 23 '20 16:01 ftomassetti

Yes, what you say is correct.

So we can have: mapChildren and transformChildren. mapTree and transformTree.

The bottom two will use the top two (if I can get that to work)

Is that okay?

matozoid avatar Jan 23 '20 18:01 matozoid

It sounds great to me. Thank you for working with me on this one!

ftomassetti avatar Jan 24 '20 08:01 ftomassetti