thoughtcoder 167 Junior Poster

That is a problem, yes. That's why public keys are cryptographically signed (look this term up) by third parties. For example, the 'certificates' that websites using https have are signed by Verisign and other organizations that browsers know about.

Suppose you're friends with Ken and Ken's friends with John. Since your Ken's friend, you and he have traded public keys, and since John's friends with Ken, he's traded public keys with Ken too. When John traded his keys with Ken, well, Ken took the opportunity to sign John's key, saying that, yes, this is in fact John. So then when John sends you his public key (along with Ken's signature), you can see that, hey, it truly is John, and you know so because Ken said so. And he said so in a cryptographically secure fashion. Now hopefully, Ken's signed your key, and that way John can trust that you are who you say you are. Sometimes (usually) that's not necessary -- maybe John doesn't care or maybe John has other ways of recognizing you, like, by asking for a password.

This is what nerds with no life do at key signing parties.

thoughtcoder 167 Junior Poster

No, it's a racist decision.

thoughtcoder 167 Junior Poster

Huh? Who is the happy suit?

thoughtcoder 167 Junior Poster

Computer janitor questions belong in the computer janitor forum.

thoughtcoder 167 Junior Poster

Oh, this is just a Hidden Markov Model problem, then, isn't it. There are dynamic programming solutions for this.

http://en.wikipedia.org/wiki/Viterbi_algorithm

thoughtcoder 167 Junior Poster

Edit: never mind.

thoughtcoder 167 Junior Poster

Wait, I misread you -- how is an nxn matrix of chars an input?

thoughtcoder 167 Junior Poster

First you say you have a sequence of chars, but then you say you have a matrix of chars. Which is it?

thoughtcoder 167 Junior Poster

You can read about XPath on the web. Places like Wikipedia's article on XPath 1.0 are a good place to start.

thoughtcoder 167 Junior Poster

You could just look at the APIs and see for yourself.

thoughtcoder 167 Junior Poster

Read the manual.

thoughtcoder 167 Junior Poster

Oh.

thoughtcoder 167 Junior Poster

If you just mean why in the world I would want to create a tree that has both branches the same that is only because I was thinking of a simple example to understand the concept...

Yaeah, that's what I was wondering :)

thoughtcoder 167 Junior Poster

That's a pretty weird error. What are you using to build and run things?

thoughtcoder 167 Junior Poster

Using sockets.

thoughtcoder 167 Junior Poster

//if list is not empty and n is not zero then create two branches. Both these branches will have a list of length one less and n one less than before. This keeps happening till the stopping condition above is fulfilled
createTree ([x],n) = Node ([x],n) (createTree (removeOne ([x],n))) (createTree (removeOne ([x],n)))

This is where you're wrong. The pattern "[x]" matches only lists of length 1. The element in the list gets bound to the variable x.

If you want the pattern to match any list, use "createTree (xs, n) = ...".

Or just "createTree pair = ..."

Your createTree function still seems a little funky so we'll see if you have more questions.

artemis_f commented: very helpful about haskell! thanks +1
thoughtcoder 167 Junior Poster

Ok, the only problem with that is that it is (i believe) not a usual way to do this. I might forget that the project used functions for conversion, and if someone else did need to use libraries written by me, they might not even think about the possibility that functions were used for conversion. Am I right?

No. I would expect people to use plain old functions. There are large downsides to explicit conversion operators -- mainly that using them makes it hard to identify the places where you're using run-time casts, because they look the same. Implicit conversion operators make it difficult to read code outside of the IDE. Which we do at my workplace, in code reviews and when we don't want to open up a file from another branch in a whole new IDE instance. Using plain old functions, calling them with x.ToBar() or Bar.FromFoo(x) or possibly new Bar(x) doesn't have either disadvantage. Since using plain old functions reduces the probability of making an error, it makes sense to use them.

On the other hand, there might be advantages to using the TypeConverter framework that I'm not familiar with. But converting between equivalent types isn't exactly a hard problem.

thoughtcoder 167 Junior Poster

So.. what do you expect to happen when you pass a list of length greater than 1?

thoughtcoder 167 Junior Poster

Why? What would you suggest instead?

Functions.

thoughtcoder 167 Junior Poster

I'm pretty sure the only way is to define an implicit conversion operator:
http://msdn.microsoft.com/en-us/library/z5z9kes2.aspx

Of course, it should be stressed: "Use it to enable implicit conversions between a user-defined type and another type, if the conversion is guaranteed not to cause a loss of data."

In fact, I think you shouldn't use implicit or explicit type conversion operators at all.

thoughtcoder 167 Junior Poster

The differences explained there are a pedantic wikipedian classification system. Hashes, checksums, and cryptographic hashes are all the same thing and are all designed for the same general purpose. The only difference between a "good hash function" and a "good checksum function" and such is that different traits are valued more intensely.

thoughtcoder 167 Junior Poster

You're missing parentheses around removeOne ([x],n) . Even then I'm not sure if that'll give what you want, but that's the cause of your current error -- the compiler thinks you're trying to pass too many arguments to createTree.

thoughtcoder 167 Junior Poster

Use reads.

> reads " 234 blah" :: [(Integer, String)]
[(234," blah")]
> reads "blah" :: [(Integer, String)]
[]

It returns a list of the different ways the desired thing can be parsed. For all standard types, this list is of length 1 or 0.

thoughtcoder 167 Junior Poster

What. What do you want. Do you want this problem solved? Maybe you should solve it, then.

thoughtcoder 167 Junior Poster

Actually, interfaces were invented as a joke. April fools!

serkan sendur commented: wtf? +0
nav33n commented: Are you out of your mind ? -2
ddanbe commented: Are you I a bad state of mind at the moment? Don't worry it can happen to all of us. -1
John A commented: I'm John A and I approve this post. +18
hirushan commented: stupid comment +0
thoughtcoder 167 Junior Poster

Um, yes, it is a hash. Is hash not a synonym of checksum?

thoughtcoder 167 Junior Poster

Make an online chatroom.

thoughtcoder 167 Junior Poster

MFC is used in MS Word? How do you know? How do you know its developers use VC++?

thoughtcoder 167 Junior Poster

Just think of it yourself. Do you think we're better at picking project topics than you?

thoughtcoder 167 Junior Poster

When looking at the image, you see how the subtree with the 8 at the root is blocked? Note that the diagram shows the results of a left-to-right traversal of the tree. It's blocked because we've visited the left subtree, with a 5 at the root, and we're going to take the min of the scores of the two subtrees. That means the score we take will be less than or equal to 5. Also, we'll take the max, the next row up, and that'll be 6. No matter what is in the blocked subtree, we'll end up taking a 6, the next row up. So there's no reason to visit the subtree.

thoughtcoder 167 Junior Poster

Not really.

thoughtcoder 167 Junior Poster

I normally program in Java and Haskell to me seems completely alien and weird.

That's because it is. I normally program in Haskell and Java seems deficient and limiting. I don't think you really get a benefit out of learning Haskell until you learn more about type classes. But the benefit is huge.

All I want to do is read the contents of a file into a big string

Note that there is a function, readFile :: FilePath -> IO String , that does the opening and closing for you.

then be able to do stuff with that string ... Apparently I cannot convert an IO String to a String? But then how am I ever going to be able to use the functions I have written that need an input String?

He he he he he he he.

If I want to read a file and pass it to a function that needs a String, it's as simple as this:

countSpaces :: String -> Int
countSpaces s = length (filter (== ' ') s)

countSpacesInFile :: String -> IO Int
countSpacesInFile fileName = do
  text <- readFile fileName
  return (countSpaces text)

-- our program counts the number of spaces in input.txt
main :: IO ()
main = do
  n <- countSpacesInFile "input.txt"
  print n

In fact, you were already doing that, no? You were reading the contents of the file and passing it to the function storeReadFile, which happened to be doing nothing to it.

thoughtcoder 167 Junior Poster

C++ doesn't have automatic memory management, which is a very big deal. This means it takes a lot of knowledge to use the language efficiently. The language might be tolerable to people who have this knowledge, but not to those who lack it.

thoughtcoder 167 Junior Poster

You don't need permission for the "brief passage" exception. She should just ask for permission, it's not like brief snippets of code are particularly valuable and it's not likely they'll deny it.

thoughtcoder 167 Junior Poster

There's no way to find the answer: you do not have enough information. You only have 2N bits of information, where N is the size of the integer types involved, measured in bits. It takes 3N bits to describe the values of a, b, and c.

thoughtcoder 167 Junior Poster

Yeah, it's really hard to understand why you wouldn't already be able to tell whether your solution was right.

thoughtcoder 167 Junior Poster

There is pseudocode in the Wikipedia article.

thoughtcoder 167 Junior Poster

You should learn modern HTML before trying to teach PHP.

Comatose commented: Taste It KHess! +12
SeanOBrian commented: good thought. clearly stated +0