[erlang-questions] how do I convert a character to an integer (dict broke the integer I put into it)

Dominic Chambers dominic.chambers@REDACTED
Sun Dec 16 12:24:21 CET 2007


Yes, the following gives me a character instead of a number (I put a
number in but I got a character out -- which may, as you say, be
identical anyway):

  dict:fetch("Key", dict:append("Key", 33, dict:new())).

but then the problem I get is that if I try to add 1 to that number I
get a badarith error:

  dict:fetch("Key", dict:append("Key", 33, dict:new())) + 1.

I have just made misunderstood what is happening here?

On Dec 16, 2007 10:44 AM, Robert Virding <rvirding@REDACTED> wrote:
> Could you please give an example of what you mean? In Erlang strings are
> just lists of integers, and a character is just an integer. So "abc" is
> [97,98,99] and $A is 65.
>
> Robert
>
>
>
>  On 16/12/2007, Dominic Chambers <dominic.chambers@REDACTED> wrote:
> >
> >
> >
> > Hi Everyone,
> >
> > I add some integers as values into a dict, but when I go to retrieve
> > them they are now strings. After an hour of googling the only thing I
> > can find online is that $c does what I want for character literals,
> > but this doesn't seem to work for character variables. I need this
> > because adding to the number I get out of the dict gives me a badarith
> > error.
> >
> > Thanks for any help, Dominic.
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
>



More information about the erlang-questions mailing list