aliaspooryorik
zackster
06/30/2023, 8:42 PMaliaspooryorik
aliaspooryorik
path
key defines the structure, the org
key is just there to try and make sense of it when working on it!aliaspooryorik
Adam Cameron
Adam Cameron
Patrick
06/30/2023, 8:59 PMAdam Cameron
aliaspooryorik
Adam Cameron
aliaspooryorik
Adam Cameron
reduce
. ALthough that said four beers and 10:30pm is not helping.
Nor is trycf.comaliaspooryorik
Michael Schmidt
06/30/2023, 9:32 PMaliaspooryorik
aliaspooryorik
s1deburn
07/01/2023, 12:28 PMfunction toTree(data, level=1, parentNode=''){
var ChildLevel = level + 1;
returnData = data.filter((item)=>{return (listlen(<http://item.org|item.org>,"->") eq level and (level eq 1 OR find(parentNode, <http://item.org|item.org>)) )});
returnData = returnData.map((item)=>{
structappend(item, {children:toTree(data, ChildLevel, <http://item.org|item.org>)} )
return item
})
return returnData
}
actual = toTree(data)
aliaspooryorik
aliaspooryorik
s1deburn
07/01/2023, 12:37 PMAdam Cameron
0
meant "no further levels". Or even if everything was 0-based, and maybe -1 was used for "no further levels".
This is not a show stopper, but it means the solution algorithm needs to dick around normalising the data before using it.Adam Cameron
tree
, you are operating at the place in the tree indicated by the path
(if that makes sense).
Can elaborate more / improve the code if it's unclear.
Thanks for the Sat afternoon puzzle.Adam Cameron
path
array.
Lucee doesn't support destructuring assignments as yet, and it makes sense to use it here.s1deburn
07/01/2023, 6:24 PMaliaspooryorik
aliaspooryorik
bkbk
07/03/2023, 8:31 AMAdam Cameron
aliaspooryorik