Talk:Tree datastructures
Attribution
My thanks to Ralf Ebert who asked this question on Stack Overflow which introduced my to the indent form. I answered his question then thought of RC. --Paddy3118 (talk) 08:28, 17 October 2019 (UTC)
Good idea for a task – a couple of thoughts.
This seems a promising kind of task – perhaps worth linking to the Functional Coverage Tree task, so that the latter can use outline parsing routines shaped up here.
A couple of thoughts:
- Perhaps JSON serialisations, both for the nested and numbered data types ?
- Unicode characters beyond the narrowly Anglo-Saxon alphabet ? Hout (talk) 23:09, 15 October 2019 (UTC)
The simplest nested JSON output (each node a value+list pair) would be:
[["RosettaCode",[ ["rocks",[ ["code",[]], ["comparison",[]], ["wiki",[]] ]], ["mocks",[ ["golfing",[]] ]] ]]]
Hout (talk) 23:43, 15 October 2019 (UTC)
Incidentally, do you feel strongly committed to that particular outline ? For some reason the word 'mock' jars a little (perhaps particularly now that we are beginning to understand more about the destructive potential of digital networks). Hout (talk) 23:43, 15 October 2019 (UTC)
Similarly, the simplest JSON output list for integer+value tuples would be:
[[0,"RosettaCode"], [1,"rocks"], [2,"code"], [2,"comparison"], [2,"wiki"], [1,"mocks"], [2,"golfing"]]
Hout (talk) 23:46, 15 October 2019 (UTC)
- Good Q's. I have a cold (streaming eyes), and will get back to you tomorrow? Thanks. --Paddy3118 (talk) 13:33, 16 October 2019 (UTC)
- On those questions.
- JSON: I didn't want to restrict the task that way, as some could make an equal claim for XML or lisp lists - I thought I'd stay more neutral on that point.
- The outline: There should be one, and only one, blah-de-blah :-) Well actually I loved my rocks/mocks pun too much and just slapped in "golfing" as a bad afterthought. I think it is very useful to have the one tree for all language examples, but I stopped mocking golfing years and years ago - its not for RC, but not for mocking IMHO. I have tried for a late save with a note, but is it too late to ask for all examples to update to use just "trolling"?
And when comparison has children?
--Nigel Galloway (talk) 13:03, 16 October 2019 (UTC)
Depends, of course, on the implementation of equality in each language. For JS I have had to hand-write a recursive eq. Haskell's Data.Tree module includes a Tree instance for the Eq class. Python's (==) equality is recursive out of the box. Hout (talk) 13:27, 16 October 2019 (UTC)