How do trees work?

I'm trying to make a project that compiles my text-based programming language BariLang to Snap! code via a homemade dictionary of supported blocks, then joining them with join.

[scratchblocks]
(dictionary (item key[if] value ({if <>::control}@addInput::grey ring)::list)⯇@addInput ::list) //My dictionary library
(join (list::list) by [blocks v]::operators)
[/scratchblocks]

I know that split and join by blocks use a tree to represent the data. But, how does that work? how would I make my own tree?

Do you mean joining multiple blocks into one stack?

I mean being able to create something complicated like

[scratchblocks]
ask [What is your name?] and wait
if < (answer)= [BlueBaritone21]>::control {
say [Hello, Me!]
else
say (join [Hello, ] (answer))
end
wait (1) seconds
say [more stuff]
[/scratchblocks]

(Where the inputs are joined, along with the stack.)

Your goal is text -> blocks, correct?

C-shapes are inputs, so you put a ringed script inside the input with the join block.

An easy way to figure out how it works is by creating the script, then split by blocks, and then analyze the resulting list.

Yep.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.