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.

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

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

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

(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.


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