Rashakil Fol 978 Super Senior Demiposter Team Colleague

MS Visual C++ Express. It should work.

Edit: as a stopgap, if you're short on time, you can run single-file C++ programs at http://codepad.org/ . But it's in your best interest to get a compiler up and running on your own machine.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A Taylor series isn't really a good way to compute this function unless you're looking for asymptotic accuracy around a particular point, rather than general accuracy along the whole thing. Also, it's a good idea to start by folding the number down to the interval [0,pi]. But suppose we did want to go with a Taylor series because that's all we knew of.

static double cos(double x) //calculate cosine
        {
            // move x to value in [0, pi] with equal answer
            x = Math.Abs((x + Math.PI) % (2 * Math.PI) - Math.PI);
            const double tf = 1.0 / 24.0, vtz = -1.0 / 720.0, fzhtz = 1.0 / 40320.0, fukit = -1.0 / 3628800.0;
            double p = x * x;
            // use Horner's method instead, just because.
            return 1 + p * (-0.5 + p * (tf + p * (vtz + p * (fzhtz + p * fukit))));
        }
    }
}

See pages 115 and 116 here for a comparison of a Taylor approximation with one that strives for a different metric of accuracy.

Rashakil Fol 978 Super Senior Demiposter Team Colleague
//load client details
            prevData = getFormData.DisplayData();

            for (int i = 1; i <= 3; i++)
            {
                
                switch (i)
                {
                    case 1: C_name = prevData[i].ToString(); break;
                    case 2: D_name = prevData[i].ToString(); break;
                    case 3: B_type = prevData[i].ToString(); break;
                }
            }

First of all, again, you should be iterating i from 0 to 2, not from 1 to 3.

Second, how do you know (at the time this code runs) that gemData has been written to? If you were getting an index error back when you had your indexes going from 0 to 2, it's because gemData had never had a three-element list written to it, because Preview_Meth was never called.

As an aside, your "for-switch" construct is a bit of a coding horror, and you should just write the three statements as follows. Also, .ToString() was superfluous too, because the values are already Strings.

C_name = prevData[0];
D_name = prevData[1];
B_type = prevData[2];
Rashakil Fol 978 Super Senior Demiposter Team Colleague

A Brainfucck interpreter. (I misspelled the name of the language btw.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Purely Functional Data Structures by Okasaki is excellent and you should read it. It might blow your mind unless that has already blown in a functional-programming-related manner.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

and its related software like Share Point also.

wat

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can compile and run the program if you want to see if it works.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yes, read through the Time Complexity of Algorithm thread. It's a very old thread and has practical and theoretical answers.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

C# is best, unless you want to consider using Scala.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Haha.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

This seems like a reasonable list.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Uh, I meant

double tsurface = tsurfaceFUNCTION(radius, height, PI);

of course.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Your syntax is invalid. You're using the syntax for declaring a function, when you should be using the syntax for calling a function:

double tsurface = tsurfaceFUNCTION(radius, height, double PI);

Note that you'll need to declare tsurfaceFunction before you use it, above the main function.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Use private static Random random = new Random(); so that the same random number generator is used across different instances of Coin.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

See if you can use "if", "and", or "or".

Rashakil Fol 978 Super Senior Demiposter Team Colleague

For this specific mechanism, you could make a function that converts your ArrayList to a byte[] and then passes that through an MD5 or SHA1 algorithm or whatnot. See System.Security.Cryptography.SHA1, for example.

You should not rely on the behavior of GetHashCode being consistent on different computers unless you can find documentation guaranteeing that its behavior is. Also, GetHashCode is a hash function that produces duplicate hash codes for different values -- it's not a cryptographically strong hash, the way that SHA1 or MD5 are, which means the probability of getting two values that have the same hash is (in the long run) very high.

There are other ways to solve this problem that don't use hashes. You can keep a version number instead (every time you change the array list, you have to increment the version number) -- if the version number hasn't changed, then the clients don't need to be updated. I don't know how .NET remoting works; another way to send information about the ArrayList is to send a description of how the ArrayList has changed -- using some kind of tuple that says things like "insert blah at index 23" and "remove item at index 14". I don't know how .NET remoting works; you might want to investigate the possibility that it does this kind of thing (version numbers or hashing especially) automatically.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm about tired of you. Do us all a favor and get banned again. Thanks.

Why don't you do yourself a favor and start charging money to do people's homework for them.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Rashakil why the hell did you insert the "retarded-mentally" tag in my thread?

Huh? I didn't insert any tags.

iamthwee commented: Bad rash. -2
Rashakil Fol 978 Super Senior Demiposter Team Colleague

So a Java interface is more important than a Java Object in your opinion? Since the purpose of object oriented programming is to use Objects? If you are talking about interfaces in general then I take that back, but you specifically mentioned Java interfaces. .

I'm talking about the idea of interfaces in general -- the fact that some particular object takes some particular set of methods, where you don't need to care what type the object really is an instance of.

Just because you're using "objects" doesn't mean you're doing object oriented programming. In that sense, the term "object" is a synonym for "value" -- you use "objects" when doing procedural programming too. "Object oriented" is really an inaccurate term to use -- "interface oriented" might have been a better term. But it's the objects that obey the interfaces, so "object oriented" ended up being the name.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

s/good/accurate/

I was asking a yes or no question, and a simple "no" would have sufficed :P

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And considering Stroustrup invented C++ I'd consider it a good book

What? Are you mentally retarded?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm new to C++, and i've seen some C and C++ code.
I tried array[] and vector<> so i see i can use both, why should i use what way to work with vectors?
Furthermore, i've seen a lot of "array[]" in this forum... so, any lead?

Just use vector<>. Never use arrays. I mean, sure, at some point in time, you'll want to learn how to use them. They are useful for implementing vectors, after all. And sometimes, occasionally, rarely, a fixed-size array is just what you want and you can't accept the miniscule overhead that using a vector gives you. People use arrays in this forum usually because they are taking classes with out-of-date textbooks or out-of-date teachers.

The main problem with arrays is that you generally have to fill the array with values, when you want to use it. And this means you've first got to create the array, and you have to know what size it is, and then you have to put the values into it. Lots of times newbies on this forum will create an array _larger_ than the amount of stuff they're putting in it, and then, when it has too much stuff, they just throw an error. Or worse, they keep trying to put more stuff in, writing into memory past the end of the array, creating undefined behavior that's hard to debug. And then you've got to keep track of how much stuff you've put in the array.

Nick Evan commented: Yes! +10
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Do your own homework.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I've created the following generic method

protected int GetSpecifiedIndexByName<T>(T collection, string itemName)
    {
      int count = 0;
      foreach (MyElement claim in collection)
      {
        if (itemName.Equals(claim.Name))
        {
          return count;
        }
        count++;
      }
    }

You have two problems with this method. One is that there is no proof that T : IEnumerable. You need to use a where clause to specify that. The other problem is that not all control paths lead to a return statement.

You shouldn't be using generics for this kind of behavior. Instead, you should just have the function take an object that implements the IEnumerable interface:

protected int GetSpecifiedIndexByName(IEnumerable collection, string itemName)
    {
      int count = 0;
      foreach (MyElement claim in collection)
      {
        if (itemName.Equals(claim.Name))
        {
          return count;
        }
        count++;
      }
      return -1;
    }

You could also use IEnumerable<MyElement> in the signature. This is a good idea because it more tightly defines the interface of the function.

protected int GetSpecifiedIndexByName(IEnumerable<MyElement> collection, string itemName)
    {
        ...
    }

So, you should not be trying to implement a generic function at all. You just want a function that takes a parameter of type IEnumerable<MyElement>.

I cannot cast the generic collection to the known collection directly i.e.

In general, you can't cast from one type to an unrelated type. For example, you can't cast something from Int32 to ArrayList. This is because there's no way that can be correct! Similarly, you can't cast a generic type, which could be anything, to the type MyCollection. You can only …

ddanbe commented: Thanks! Very instructive. +4
sknake commented: nice++ +5
DdoubleD commented: good explanation regarding down casting! +1
Rashakil Fol 978 Super Senior Demiposter Team Colleague

OOP is the use of interfaces (as they're called in C# and Java) and the creation of things that obey those interfaces. This is the necessary and sufficient condition.

Some languages with support for object oriented programming are better than others (for example, Scala is better than Java), but there's no true best OOP language because they have different uses -- whether you need type safety, whether you need memory safety, whether you want to run on the JVM or .NET, whether you need efficiency, whether you need to use some particular library, and so forth.

Now let's see how long it takes before some idiot starts babbling about encapsulation.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

atoi(text[0]) will not work because atoi expects a char*, not a char. That half of NeoKyrgyz's answer was basically useless and dumb.

If you want to convert the character "c" representing the decimal digit n to the integer n, you can do so with (c - '0') . That's the same as what NeoKyrgyz said, because '0' is just a fancy way of writing 48 . You'll note that '0' == 48, '1' == 49, ..., '9' == 57. If text is a string containing "0R14", then text[0] will evaluate to 48.

atoi is for converting c-style strings containing sequences of digits into numbers, e.g. "123" -> 123

Rashakil Fol 978 Super Senior Demiposter Team Colleague

i have no idea where to even start any help would be greatly appreciated.

Look at the behavior of the division and modulo operators.

i would really appreciate a hand here!?

Learn how to take substrings and how to append strings to one another.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Q. How can 3/2 be 1? I thought it was 1.5.

A. Lookup "quotient" and "remainder" on the Internet.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Okay, all a pointer is is a number (indeed to see it in C use the & operator).

What the are you talking about? You don't use the & operator to see the memory address.

Its a number standing for a memory address (like a co-ordinate). You use -> to operate on the thing which the pointer points to.

Ah, yes, to "operate on something."

Simply put, a linked list is a data structure which allows for dynamic memory.

Simply put, a linked list is a tinkledoo which allows for dynamic dragonsaur.

On the other hand, an array, for example, is one contiguous block of memory of a fixed size. This is easy to code, but not very flexible. Linked lists address this issue by allowing for variable size and (depending on implementation) faster searching, at the cost of complexity

No, linked lists do not allow for faster searching; then it would be something other than a linked list.

Simply, there is a pointer (basically a numerical memory address) called head, or start etc....

Basically. Basically (basically).

This points to the first element (node) in the list (an object - linked lists are a great example of why OOP is good).

No they aren't. You don't have any clue what you're talking about. Linked lists are found in every modern language, no matter whether the paradigm is functional, object oriented, Javastyle, or ball-of-parentheses. That has nothing to do with object oriented programming.

If the list is empty, this points …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I smell stackholm syndrome.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Just look at the curriculum. Course descriptions are available on the school's webpage. It should clear up most questions, and if not, you can ask here or elsewhere questions about what particular course descriptions portend.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yeah. i have just been noticing people putting things down for absolutely no reason.

Lawl.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If plugging numbers into formulas is beyond you, you're studying the wrong subject.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

This seems like an excellent way to be passive-agressive.

MosaicFuneral commented: Tis true. +0
iamthwee commented: hell yeah +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can't calculate precise values of T(3) without knowing the precise value of T(1).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I would recommend reading Code Complete, 2nd Edition.

This is like the most useless book I've ever purchased.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm getting started myself and bought FPGA Prototypeing by VHDL Examples, the Xilinx Spartan-3 Version, by Pong P. Chu, and I ordered a Spartan 3E from Diligent, which should come Monday. I have only seen good reviews of the book, and if you wait a few weeks, I'll tell you how it goes.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Blah blah blah, blah blah blah.

The answer is that Linux, Windows 7, and Mac OS X are good, but Solaris is not. Hope that helps :)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Maybe it's base-64 encoded. Try assuming that and decoding it.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

All the threads that we create using Java library or C#(on .NET) library are user level thread.

Aha! Now you've made the question more interesting.

1. A user level thread can block the entire process on a system call. What does this mean.

When you make certain kinds of system call (the blocking kind), you end up blocking the kernel-level thread your code is running in. Other kernel-level threads are not blocked. If your process only has one kernel-level thread and is managing its own threads, control isn't going to return to the program's thread until the system call finishes. So it has no opportunity to switch which user-level thread is running.

On the other hand, you could have a mix of user-level and kernel-level threads, where the scheduler runs in a kernel-level thread of its own and user-level threads run in the other kernel-level threads. Then if a user-level thread makes a blocking system call, the scheduler can still resurrect other user-level threads inside a separate kernel-level thread, preventing user-level threads from actually blocking the process.

If the JVM and .NET use user-level threads in their implementations, well, remember that C# and Java programs compile to bytecode and cannot unpredictably make system calls. So the interpreters will use different schemes, like translating all blocking system calls into nonblocking versions, and doing I/O from a separate kernel-level thread, to avoid blocking the other user-level threads they have running.

2. Can kernel level threads be ever blocked???

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you understand how user level threads are implemented, you'll know the answer to your question. If you don't understand that, then you're just memorizing sets of discrete facts. Which would be retarded.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Ask yourself how user threads are implemented, and the answer reveals itself...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

On x86 systems you can do a locked add in one instruction.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I would use a List<> instead of an array, because you can create a List<> and then add new elements to it.

string[] someArray = new[] { "Alpha", "Bacta", "Cata", "Dooku", "Ephem" };
List<string> xs = new List<string>();
foreach (string s in someArray) {
  if (xs.Length < 3) {
    xs.Add(s);
  }
}

There you can see one example of building a list with the first three elements of some other source of information. (That's a pretty bad example -- instead you'd want to end the for loop somehow immediately after you've reached three elements.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The happy police strike again. It was good knowing you serkan -- I will make it very dry for you.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Maybe you should learn how to code.

http://htdp.org/
http://docs.python.org/tutorial/

Rashakil Fol 978 Super Senior Demiposter Team Colleague

hey can someone tell me how to make 10 nodes in the code tht i have made...thts the one way i could think of...

Try figuring it out yourself. Then maybe you'll learn something.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What courses are available and which ones are good depends on which school you're going to. There is a lot of variety in the ways various computer science departments teach.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why don't you keep track of how many values the user has entered, and use some mechanism to see if that number's 10?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can't be helped with such a vague request; ask friends and coworkers, or just fiddle around.