0

I am writing my thesis right now and i wonder is that possible to give the function as an input and get the mathematical equation of that function for putting into thesis.

For example this is a function

        public static bool CompareThresholdPassWithList(int irThreshold, List<string> srlstWord1, List<string> srlstWord2)
    {
        int irSameCount = 0;
        int irMinOne = srlstWord1.Count;

        if ((srlstWord2.Count) < irMinOne)
            irMinOne = srlstWord2.Count;

        foreach (string srVariable1 in srlstWord1)
        {
            if (srVariable1.Length > 0)
            {
                foreach (string srVariable2 in srlstWord2)
                {
                    if (srVariable2.Length > 0 && srVariable1 == srVariable2)
                    {
                        irSameCount++;
                    }
                }
            }
        }

        if (((irSameCount * 100) / irMinOne) >= irThreshold)
            return true;
        else
            return false;

    }

Actually generating some output that i can use in my thesis would be sufficient. Maybe pseudo code or flow chart ? or else that can work.

C#

Thank you.

Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
  • What as in something that outputs predicate calculus? – Tony Hopkinson May 05 '12 at 19:52
  • @sleiman jneidi what is not clear for you ? – Furkan Gözükara May 05 '12 at 20:55
  • @Tony Hopkinson i did not understand what you mean. – Furkan Gözükara May 05 '12 at 20:55
  • How would you expect to represent this method as a mathematical equation? There's no way to do it automatically (I'm not even sure it's possible to do it at all) – Thomas Levesque May 05 '12 at 21:01
  • Clearly somebody ought to write a thesis about it. It isn't simple and it isn't obvious. A thesis is supposed to be hard. You can quote prior literature but certainly not an SO answer that shows you how to do it. Which would be required under the CC terms at SE sites. Arriving at a "it is too hard to be practical" is actually a valid thesis conclusion. You'll have to prove it though. Luckily not my problem, nor anybody else's problem at SO, it's yours. Quite comparable to what happens when you get a real job. Good luck! – Hans Passant May 05 '12 at 22:04
  • Predicate calculus was a mathematical description of a requirement. Idea was you did that, then you you did it for the function, then you could 'prove' that one was the other. Backwards E, upside down As, super and subscripts with loads of parentheses and brackets, you'll love it. :( – Tony Hopkinson May 06 '12 at 11:17
  • @Hans Passant what are you saying ? :D I am trying to express this function in a global way which means who does not know C# will understand. – Furkan Gözükara May 06 '12 at 15:10

2 Answers2

1

From your description, it sounds like you might be better off working with a functional language, such as Haskell, rather than C#, which is essentially imperative.

For a function to be translatable into a mathematical formula, it needs to be referentially transparent, meaning that it does not cause any side effects during its execution.

Douglas
  • 53,759
  • 13
  • 140
  • 188
  • That's a good point, when I did some stuff like this it was from pascal, so there was a lot of 'erm translating going on. – Tony Hopkinson May 06 '12 at 11:19
  • The point here is expressing it in a global way which means the engineer who is reading it does not have to know C# language or any other programming language. – Furkan Gözükara May 06 '12 at 15:11
0

I don't know the kind of terminology you'd probably want for a thesis but I can explain what this code is doing which I think if you understood you'd be in a better position.

You have two sets of words (Set 1 and Set 2), this code is determining the intersection of these two sets and then determining if the size of the set defined by intersection is greater than a defined percentage of the size of the smaller set. If there are duplicates in either set, then these will be counted more than once and empty strings are being excluded from the set defined by the intersection.

I'm not sure why the code would be written like it is, it seems very inefficient and I can't imagine a use case for this behaviour, I suspect it's buggy.

This was from a quick read of the code, If it were my thesis, I'd use something like Snippet Compiler to run the code with sample inputs to test the outputs.

joocer
  • 1,111
  • 1
  • 7
  • 11
  • The question is not related to code. It is about expressing it in a global way that the reader does not have to know that specific coding language. – Furkan Gözükara May 06 '12 at 15:11