Haskell, 56 Characters
an illegal, but quite short definition is this:
p n=read n
(writing just p=read would not work because of the monomorphism restriction; if you're not a haskeller, don't worry about this)
basically, this just calls to the library parsing function.
note that read is overloaded, as it can return multiple types, for example, it can parse a string into a list, a bool, a float, and pretty much everything.
so, here is a version which specifically parses integers:
p n=read n::Int
the :: means that read n must be of type Int.
but although not stated clearly by the question, these are cheating, so here is the real ungolfed commented version:
parse "" = 0 {- if the input is the empty string, return 0 -}
parse ('-':xs) = -parse xs {- if the input starts with '-', bind xs to the rest and return -parse xs -}
parse (c:xs) = (ord c - 48) * 10^length xs + parse xs --the general default case
{- explanation: there to the left are subexpressions of the solution, and to the right their meaning.
ord c the integer representation of c
ord c - 48 the value of c (as long as c is a digit, of course)
length xs the length of the rest of the string
10^length xs 10 to the power of the length of the rest; also the value of c's place
(ord c - 48) * 10^length xs the value of the digit c
(ord c - 48) * 10^length xs + parse xs the resulting number
-}
golfed version:
p""=0
p('-':x)= -p x
p(c:x)=(ord c-48)*10^length x+p x
note this solution assumes the input is a number.
2By "Points will be awarded based on popularity.", do you mean that the answer with the highest score (upvotes minus downvotes) wins? – ProgramFOX – 2014-08-01T06:36:43.787
2I'm not sure why this is a popularity contest. There doesn't seem to be a lot room for mind-blowing creativity without any restrictions. Why not just make it a good old code golf? – Martin Ender – 2014-08-01T14:47:17.360
does it also need to work with positive integers and zero? – Foon – 2014-08-01T17:33:16.280
I assume that this is specific to languages that have strings and integers... Better explicitly state that? – None – 2014-08-01T18:11:31.720
is there a language that doesn't have any way to represent both strings and integers? – proud haskeller – 2014-08-01T20:21:40.850