Rashakil Fol 978 Super Senior Demiposter Team Colleague

if they're evenly distributed random numbers, n1 = n2 = n / 2, and 3 * S1 = S2 = 3*S/4, approximately. I do not feel like calculating the actual probability distributions of these values, though...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It helps with reach too.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Create a posting games forum. And don't let that forum's posts contribute to the post count.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I think Haskell is pretty cool. At least in the sense of if anybody claims that OO is the end-all of everything, you can say no, functional programming is, tell them that Haskell is better than any OO language, and then you won't have to hear back from them for ten years as they try to understand how a list could possibly have an infinite number of elements.

I think right now that Perl 6 is pushing the awesomeness and coolness envelope pretty far.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You people need something to do in your free time.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

i have gon through w3school about xml. i know what it is ext.but still not able to get idea how it is useful and anybody show the website example to show how xml is useful.thanks

It's useful if you want to store data with ten times the space and three times the verbosity you need. It's also useful if you want to transform your data with XSLT into other XML documents, but this time with twenty times the verbosity you'd get in any other language. XML is useful since it's simple and there are XML parsing libraries lying around waiting for you to use them, in many programming languages. Never mind that handy facilities for parsing and manipulating hierarchal expressions were built into Lisp more than a quarter century ago...

As a standard way of formatting data, it's best used for communication between foreign programs, and perhaps for human-readable configuration files. But it's not good to use an XML document as if it were a database, unless you enjoy slowing your computer down.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You could insult someone. And we don't want that, do we?

Insulting people is a good thing. People feel insulted when you tell them things that they know are true, but are denying to themselves or are afraid of being true. Many insults are used to deflate others' sense of self-importance. For example, when one middle-schooler calls another a "homo," that's an insult not because one has communicated an opinion of the other's sexuality, since usually both know they're obviously heterosexual. It's an insult because one is informing the other that he's not popular, which the other strives to be and tells himself he is.

I knew a high school math teachers that would almost bully his students. If you called him an idiot, he'd be offended, because he really was one. But Stephen Hawking would not be offended at this, he'd just be amused.

Another example is the famous, "I may be drunk, but tomorrrow morning I'll be sober, and you'll still be ugly." The woman was trying to fool herself that she was beautiful, but she knew alternative was really true, hence she was successfully insulted.

Insulting people, especially the self-important types, justly tears at the pretensions they build about themselves.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I just realized that I forgot I had left some money in my Paypal account. I'm richer than I thought I was!

Well, closer to achieving zero net worth, anyway...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Don't forget

return three; // uses copy constructor

some_function(three);
// uses copy constructor unless passed by reference

Of course, a compiler could behave magically and optimise away a copy constructor call.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Second, the following doesn't follow a basic tenet that I follow when writing code for myself. That
tenet is to write no more than a single function before I compile looking for errors.

That's not so horrible. On one homework assignment, a sparse matrix implementation, I handed in code with multiplication, addition, subtraction, and assignment implemented, but I forgot to check if it even compiled, not to mention worked.

I got very lucky on that one :-)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Wow, you people are weird.

Agreed.

6 feet 3 inches, or 1.905 meters

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I think a good solution is to check if you've reached a node the second time only on nodes whose distance from the beginning is a power of two. This lets you find a loop in linear time. From this you can also use divide and conquer to find the starting point of the loop in linear time.

Using a hash would also be linear time (usually), but probably slower.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What's the coolest programming language? And why?

Oh boy this should be fun :->

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There is pretty much no reason to use shell scripting if you're guaranteed that your environment will have perl, unless that's what you happen to prefer. Except for maybe some really small stuff.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

loller, are you 16 years old? I make an exercise out of guessing people's ages based on their writing style and would like to see how accurate I am.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Um, yes. You might want to check out a variant I made that uses bits instead of bytes: http://www.rpi.edu/~hughes/boof/


It's pointless, mere fun really.

So is living.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The first time through the loop, the value of i is N, so we know it takes 3N+6 operations in the loop. The second time through the loop, the value of i is N-1, so it takes 3(N-1)+6 operations. The third time through, the value of i is N-2, so it takes 3(N-2)+6 operations. And so on, until the last time through the loop, the value of i is 1, so it takes 3*1+6 operations. (The second-to-last time through the loop, the value of i is 2.)

That gives [tex](3N+6)+(3(N-1)+6)+\cdots + (3(2)+6) + (3(1) + 6)[/tex] operations.

Then I rearranged terms and pulled out the 3 to get the second line.

Then, using the formula N+(N-1)+(N-2)+...+3+2+1 = N(N+1)/2, I substituted.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Which step don't you get? Do you understand how I got to [tex](3N + 6) + (3(N-1) + 6) + \cdots + (3(2) + 6) + (3(1) + 6)[/tex]?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Dune, Snow Crash, and Surely You're Joking, Mr. Feynman!

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Windows XP, Mac OS X, and Linux (Ubuntu).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Is this in C or C++? What is your definition of 'string'?

If you're using an array of characters with a zero at the end, then you can use the procedure strcmp(x, y) to compare the contents of two arrays of characters, whose memory addresses are x and y. For example:

char z[20] = "Foobar";
char t[12] = "Foobar";
int ret = strcmp(t, z);

Both t and z are regarded as equal strings by strcmp. strcmp returns 0 when two strings are equal, a negative value when the string on the left is 'less' than the string on the right, and a positive value when the string on the right is 'less' than the string on the left (maybe it's the other way around -- I forget and you'd have to try and see).

Now, if you're using C++, you'll want to store your information in std::string objects, since that's just easier. You can compare std::string objects using the normal == operator. If you decide to go with char*, C-style strings, in C++, you can still use strcmp, though.

Note that in C you should include #include <string.h> at the top of your file that uses strcmp, since the procedure is declared in that header file.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Beware of the performance costs, though. If you just pass a vector, as in the code below, you'll end up copying the entire vector, which takes an amount of time proportional to the length of the vector. Unless the compiler is unreasonably intelligent, which is never the case.

int foo(vector<int> x) {
   return x.back() - x.front();
}

So in situations like these, pass the object by reference, so that x refers to caller's vector.

int foo(vector<int>& x) {
    return x.back() - x.front();
}

The second version takes a constant amount of time.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

With FAT based filesystems it was rather helpful, but with NTFS and filesystems seen on Unixy platforms, they already make efforts to minimize fragmentation, so unless your disk is nearly full, you shouldn't run into any problems.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Don't bother with defragmenting.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If all you have is an AK-47, everything looks like an enemy combatant.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Iraq doesn't cost many American lives, only several thousand. We should stay in there, then invade Iran, followed by Pakistan, India, Sri Lanka, Bangladesh, Burma, Thailand, and so on. After we conquer Australia we'll get two extra soldiers every turn, and that should make rolling through Asia like a walk in the park.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I read that five years ago.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm having trouble getting an overview of data structures. I've read about the different file types and the different ways of indexing but I can't see the whole thing as an overview. I know theres some logic somewhere! for instance, how do I find out the information about all the records listed in a hash file?how do I get the list in the first place?

It will help to better explain what your current thinking is. Answer this question: If you're talking about data structures, what are you talking about file types for?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Why is my post edited? Boolfuck just happens to be the name of the programming language. If that offends people, then there's some disease that they have.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Here's a recursive one in Java since it seems no one has done one recursively or done one in Java.

Jessehk and I both did recursive ones, actually.

Here's a Boolsmurf version:

+[>>[>]+<[+
<]>;>;+>;+>
;>+;;+;;;+;
+;+;+;;;;<[
<]+>[+>]+<<
<<<[<+]>>>>
+[+<+]>+[>+
]<<+<+<<<]+
;>;;;>;;<;;
;;;;>;;<;;;
+;+;>;+;;;;
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Be more specific about what you want to do.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Message box? In Mac OS X you generally don't use a message box, or when you do, they fold down from the top of the window. Assuming you have a window already, this is the way you should do things. You'll probably have better luck looking in that direction. Maybe somebody will come along with a slicker answer than that.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

When you look at how much money is spent to keep ONE prisoner in prison, then it's just not fair to let them live.

If you compare this to the cost of actually executing people, it's the other way around.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

People who start flamefests like these deserve the death penalty.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Here's um, another Scheme version:

(let loop ((i 1))
  (cond ((<= i 10)
         (display i)
         (loop (+ i 1))))

And another...

(define (range n m)
  (if (> n m)
      '()
      (cons n (range (+ n 1) m))))
(for-each display (range 1 10))
Rashakil Fol 978 Super Senior Demiposter Team Colleague

I would've done one in Tama, but it's not Turing complete so doesn't deserve it.

Ruby:

(1..10).each { |x| puts x }
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Haskell:

main = mapM (putStr . (++ "\n") . show) [1..10]
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Perl:

print "$_\n" for 1..10
Rashakil Fol 978 Super Senior Demiposter Team Colleague

I don't think it's a question of math, people just misinterpreted the problem (or had read the first misinterpretation of the problem). Why would I tell anybody what my avatar is?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That link has nothing to do with finding the global extremum, which is located at -b/2a. (If a = 0 then there is no global extremum.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

No, that's not what's being asked for. honeybleak, do you know how to do the calculation on paper?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you understand the language you're using, then you should have no problem running through the code by hand or in your head to see what happens, given some particular program. So do that.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I have a dim view of 'free market economics'. I don't trust it, really. In theory, competition is healthy. In theory, companies will work to improve their services or lower costs to remain competitive.

Theory shmeory, just look at which countries have had freer markets and which have not over the past one hundred years and compare their quality of life today.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'd say the applied math program is as 'good' as the CS program, since it mixes good math classes with what I consider the good CS classes. This is coming from somebody majoring in math or applied math who sneaks around CS classes. If I were in your position I'd go for the applied math program, but that might be just because I'd like to avoid the "Report and technical writing" and "Business professional communications" classes.

The reason I chose math at my school was simply that this choice effectively made every course I take an elective, in that I'd have taken it anyway. Maybe you should look at what courses you'll have to take, but wouldn't have chosen out of your own free will. Whichever major forces you to take fewer undesireable courses is the better program.

Of course, what you consider 'good' might not be what I consider 'good' when it comes to applied math and CS.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Net neutrality is a silly notion if it's easy to set up your own network and connect yours to others'. If that's the case, then competition will take care of problems and distribute access efficiently and fairly. By 'easy', I mean if there are loose local regulations regarding burying of fiber, and freer regulation of the wireless spectrum. Ideally, network access would be paid by the byte, and you wouldn't choose _one_ ISP; packets would go over whichever network is cheaper and everything would be billed automatically.

However, if the governments put restrictions and fees and local permits in the way, then the only solution is regulation, with laws requiring network neutrality. It's one set of regulations trying to counterbalance another set of regulations, which is pretty silly, but common.

The conclusion? Imagining things is fun.

And overregulation by the government is the only thing that can really get out of hand. If the free-market way of doing things gets out of hand, the government can pass laws putting some controls on things (or use existing laws). If government regulation gets out of hand, it's harder to fix.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Count the total number of basic operations, those which take a constant amount of time. That's all there is to it.

For example, the code int Sum = 0; is 1 basic operation. Then j = 0; is another basic operation. Then j < i forms yet another basic operation. Count these, and you get your time complexity.

For example, take the loop,

for (j = 0; j < i; j++)
  Sum++;

In this loop, you end up evaluating j = 0 once, j < i a total of i + 1 times, j++ i times, and Sum++; i times. So the total number of basic operations is: 1 + (i + 1) + i + i = 3i + 2.

Then take the block of code,

int Sum = 0;
     int j;
     for (j = 0; j < i; j++)
    Sum++;
   cout << Sum << endl;
   i--;

Here, we have int Sum = 0; taking one operation, for (j = 0; j < i; j++) Sum++; taking 3i + 2 operations, cout << Sum << endl; taking 1 operation (or 2 operations, depending on how you look at it, but the whole thing takes a constant amount of time anyway). Then i--; takes one operation. So that's a total of 1 + (3i + 2) + 1 + 1 = 3i + 5.

Then take the block of code,

int i = N;
while (i > 0)
 {
[b]we calculated this to …
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Read the wiki on Haskell and my head went /splode

You know, come to think of it, there are no good Haskell tutorials. That's pretty sad. Okay, learn Scheme first.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Learn Scheme and Haskell. I don't know what Scheme's best applied to (probably teaching Scheme, really), but I think learning it will make you a better programmer if you let yourself go from any ways of thinking you've acquired with C++ or Java. C++ and Java basically form a subset of Scheme's (and other Lisps') features, even though Scheme is a much smaller language. (But they C++ and Java much bigger and better libraries, plus operating system interaction.)

Haskell takes a much different approach to programming than Scheme, C++, and Java, and is worth learning for that reason alone. As for applications, a working implementation of Perl 6 has been (is being) built with Haskell.

Avoid these languages' communities, though. It seems like Scheme people are elitist fools that sit around and lament their language's unpopularity, while Haskell people smoke pipes on the deck of a cruise ship and discuss category theory.

Perhaps the best reason to learn them is that they'll make you a much better C++ programmer. The previous sentence is definitely true.

Learn Haskell first.

[edit]
and it would never hurt to learn a bit of assembly language, just so that you know what's ~really~ going on.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I just phrased myself incorrectly. Each element is pointing to the start of a string. I'm trying to understand the arithmetic involved in accessing an individual character from one of those strings.

Okay. The trick is to remember that in C, an expression x[y] is just a cute way to write *(x + y) .

Seriously, writing x[3] is equivalent to 3[x] . Maybe C++ is a bit more strict.

So, applying C's order of precedence, strings[4][2] is equivalent to (strings[4])[2] , which is (*(strings + 4))[2] , which is *(*(strings + 4) + 2) . So, strings + 4 is the location of a memory address. Then *(strings + 4) is the memory address of the first character of an array of characters. Add two to that, and you get the memory address of the third character. Then dereference that, and you've got the character itself.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

'In'? You're probably thinking the wrong way. Each array element contains the address of a bunch of characters. So strings[3][0] == strings[4][0] compares two characters: the character located at the memory address computed by the expression, 'strings[3]', and the character located at the memory address computed by 'strings[4]'.