Adding Branches to a Recursive Tree - mit-scratch

I am struggling to build new branches on my recursive tree, and I would like to make this tree with a variable.
Any suggestions?

Did you forget to add a repeat until _ loop? That would probably help...

Related

what makes a variable be visible (intellij idea)

With intellij idea, how do I find out what makes a variable be visible?
An example of when it is hard:
Suppose you look at class A, and you see a variable something. If you jump to source you see that it's defined in trait X. But you don't extend trait X directly. What do you extend, then, that makes this variable visible? If you have a deeply nested hierarchy, tracking can be hard.
Any recommendations or solutions?
EDIT: Please vote for the feature if you're interested: http://youtrack.jetbrains.com/issue/IDEA-124369
I don't think that IntelliJ IDEA has any shortcut for "finding what makes a variable visible".
However you can determine it using the "Find Usages" option (Alt + F7). For example:
import java.nio._
object TempObj extends App {
def func = 2
val p = file.Paths.get("some-path")
func
}
So Find Usages on "file", tells you that its from the Package "file" (in heading of the new Tab it also shows the complete package name, ex: Find Usages of java.nio.file in Project Files).
Whereas Find Usages on func will tell you that its a Method (And the Tab heading now says: Find Usages of func() in Project and Libraries)
So now in way you can determine, what exactly makes the variable visible. This also works for imports since it shows the package from which it is imported and you can then look for import of that packages.
I know of two almost-solutions to this problem.
Go-to-declaration, as you mentioned, solves this problem in the case of local variables.
More generally, the "find usages" feature gives you a neat little breakdown by type and file of different uses of the variable. From this you can see if it's involved in a static import.
It's not perfect, but with a moment's thought these two are generally sufficient to figure out what you want.
Use ctrl+b or F4 to jump to source code. Alternatively you can use ctrl+shift+a to get option/action. You can find shortcuts at http://gaerfield.github.io/ide-shortcuts/ as well. Hope it will help.
From what I understood you want to see the code that creates an Object you use, for instance Mystery someMystery;.
That gives you two options to populate someMystery:
someMystery = ... where ... is your code to populate
someMystery and if that is the case you should follow
that code (with ctrl+B as far as you need to) to the point where it
actually creates the Mystery object.
Use CDI to populate that object instance for you, in which case you should look into the CDI mechanism in order to see in what way the object instance is populated.
In either way IMO there is no way to know for sure if the someMystery instance is of some more concrete class than Mystery, because it is decided in runtime, not in compile time, so your next bet would be to run the program in debug and see what object goes into someMystery, although you are not guaranteed to get the same type of object every time.
PS. My answer is based entirely on my java understanding of the topic, can't say if it is valid for scala also.
This might not be exactly the answer you were hoping to get.
However, quoting yourself,
If you have a deeply nested hierarchy, tracking can be hard.
Have you considered using composition over inheritance? Perhaps this would remove the need for the feature you are looking for.
Deeply nested hierarchy doesn't sound good. I understand your pain about that.
When you override vals or defs there is a little circle next to the line number that shows where it is from even when it is from nested hierarchy. Hovering over vals with the command key down also shows you a little tooltip where it is from.
Does this help?
https://youtu.be/r3D9axSlBo8
if you want class, field or method to be visible, you need to implement them as public. If it was your question.

Finding the age of change sets in a merge

I'm trying to find the time it takes from checking in a change to a branch to that changeset getting merged up to a parent branch. I've been playing with the TFS API and have tried to use the GetBranchHistory and QueryMergesExtended methods but they don't seem to return anything in a reasonable time frame.
Can anyone point me in the right direction to get this information?
Thanks
I think you can use the TrackChangesets method for that. I haven't tried myself but looks like this is what you are looking for.
Looks like the return type VersionControlBranchVisualizer has what you are looking for.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.teamfoundation.versioncontrol.versioncontrolbranchvisualizerext.trackchangesets.aspx
For tfs2010 you can use VersionControlServer.TrackMerges for get IEnumerable<ExtendedMerge>. See example here (method TrackMerges).

Clone a Gtk.Button from gjs

How would I go about cloning any widget from gjs, similar to the C response given in https://stackoverflow.com/a/3030603/1829961? I have not been able to find a way to call list_properties although it is listed in the GModule gir file. Or do I have to use GIRepository, manually walk the GIR type hierarchy, emulating that which g_object_class_list_properties is supposed to do? Or another straight forward way I'm totally missing here?
Here is some code that will do that.
It takes a similar approach to the quesion you linked, but since there is no G_OBJECT_GET_CLASS() in GJS, it uses GIRepository instead -- which is an extra dependency that you need compared to the C solution.

I can't delete a method using eclipse refactoring?

I have a method which I want to delete. This method is being called from n number of classes. I want to delete this method using refactoring and also make eclipse delete all calls to this method rather than go and clean up in each file. I could not find a straight way to do this from refactor (I am using ganymede)
Delete the method body
Then select the method
Refactor -> Inline
I don't think it can be done through refactoring. You can do a Search and replace using regex though.
CTRL-H to bring up the search replace dialog

Destructively reverse every cons node in an s-expression

Any ideas how to go about this? I am trying to not create any new nodes.
Call nreverse.
Draw a standard cons-cell diagram of what a list with 5 elements or so looks like. That should give you a big clue right there.
Don't forget to keep a reference to the last cell in the list, which will be your new list head when done.