Category Archives: StackOverFlow

Stack Overflow is a question and answer site for professional and enthusiast programmers.

recursion within a class

I am trying to place a recursive formula inside a class statement

class SomeNode:

    def __init__(self, a):
        leng = len(a)
        half= leng/2
        self.child1=SomeNode([a[i]for k in range(leng)])
        self.child2=SomeNode([a[j] for j in range(leng)])

    def recursfunc(self):
        print self.firstnode

However I keep getting the error message NameError: global name ‘recursfunc’ is not defined

read more

How can I multiply two matrices in C#?

Like described in the title, is there some library in the Microsoft framework which allows to multiply two matrices or do I have to write my own method to do this? // I’ve got an answer to this by now

Second question:
I wrote this multi class with a MultiplyMatrix method but it doesn’t work like I want to. Can anyone help and tell where I made a mistake?

class multi
        public void MultiplyMatrix(double[,] _A, double[,] _B, int _n, int _m, int _r)
            int n, m, r;
            double si;
            n = _n;
            m = _m;
            r = _r;
            double[,] A = new double[n, m];
            double[,] B = new double[m, r];
            double[,] C = new double[n, r];
            A = _A;
            B = _B;
                for (int i = 0; i < n; i++)
                    for (int j = 0; j < r; j++)
                        si = 0;
                        for (int k = 0; k < m; k++)
                            si += A[i, m + k] + B[k, r + j];
                        C[i, r + j] = si;
                for (int i = 0; i < C.Length; i++)
                    for (int j = 0; j < C.Length; j++)
                        Console.Write(C[i, j]+" ");
                        if (j % 3 == 0)
            catch (IndexOutOfRangeException) { } // I always get this exception



read more

How do I create a suggestion drop-down list like Google’s?

It’s a theoretical question at this point in time, but something I’m probably going to want to do long-term.

When you go to and start typing a search, it’ll provide you with suggestions in a little drop down menu. I’m reasonably certain that they use AJAX to send what you’ve typed and get a list of possible suggestions back. What I’m trying to figure out is how they actually display that list. It looks like a simple <select> drop down list, just without the actual select box at the top. There is zero doubt in my mind that it’s something as stupidly simple as a CSS trick that divides the select box from drop-down list it produces or an input type other than select, but I’m drawing a blank.

read more

Working with onStateChange of Youtube player

I was trying to use the onStateChange property of Youtube videos, And I could not get it to work. I searched a lot over it but could not really understand how it works. Here is the code which I tried, I added a console.log, which does not get called. Can someone help me?

This is my code:

    <script type="text/javascript">
        function onYouTubePlayerReady(playerId) {
            var player = document.getElementById("YTplayer");
            player.addEventListener("onStateChange", "onplayerStateChange");

        function onplayerStateChange(newState) {
        <object style="height: 390px; width: 640px">
            <param name="movie" value="">
            <param name="allowFullScreen" value="true">
            <param name="allowScriptAccess" value="always">
                width="640" height="390"

read more