Here is some binary trees but in Hopscotch:
Recursion where each branch is a smaller version of the whole thing
- recursion is where each sub-problem 'looks like' the original problem
I was going to leave the more formal stuff to another topic but may as well mention some things here
Here is some comparison between some code in another drag and drop language and the code in Hopscotch, the main difference is that the other language has functions and arguments whereas Hopscotch does not:
Luckily we can replicate this feature :
The thing is though, when you use a variable each time you recurse the function, you want to be able to retain that value ... it's a bit hard to explain.
But you can see in the code that each time I call the ability again, I multiplying
length by a ratio, and it will remain that way even when I need to use the previous value that
length was. Hence the undoing of that by dividing the length by that same ratio after the call...
(There's another way to do the 'undoing' of an argument, and that is by undoing it at the end of the ability, but I don't think all of this makes much sense until someone sees it for themselves though.)