Placing reporter blocks inside of other reporter blocks programmatically

First of all, I understand this is somewhat useless. I do know that there are other ways of going about this. This isn't something I'm really want to do and more of something I want to know.

So, let's say you're making a custom block. And you want the custom block to return a nested reporter block from a string. So you would give the block the string "^+*", and it would return
untitled script pic (3)

Once again, I understand this is completely and utterly pointless, you could just give it a string like "3^2+4*85" and then have calculate 3^2 and 4*85, then add 9 and 340 together, sending the output. If you were a mad lad you could just use the dangerous eval() function. So if you have anything better to do, I'm fine with that.

The reason I'm asking this question is because it is possible. You'd probably have to use objects and functions created for the inner workings of snap, but that's why I chose this topic. Also, I've only been a programmer recently, so I think the answer to this question would help me learn. But the main reason is it would be interesting to know.

What I've tried:
First thing that I tried was:
untitled script pic (3)
Now I'm sure why this didn't work, but I'm going to guess it's because it's running with the rings:
untitled script pic (4)
instead of without them. Next, I tried this:
untitled script pic (5)
And then:
untitled script pic (6)

And finally:
untitled script pic (7)
and then I gave up.

I tried looking at the code for snap, mainly block.js and object.js, but I couldn't figure out how to return a block like the ring block does internally. Thanks in advance!

fortunately for you i made a library that does exactly that


i have no idea if there's a function already written in the engine code that does that, the javascript code in those blocks are really big (except for the copy block) (and the put script after script block) (and the blocks in block) (oh and espesically the # of slots in block that's just one line of code because i found a function that did what i wanted it to do) (ok so basically just the ones concerning slots)

thank you so much! I'll try to figure out how it works.