ETk problem

Luke Gorrie luke@REDACTED
Fri Jan 21 12:35:07 CET 2000


Torbjorn Tornkvist <tobbe@REDACTED> writes:

> > ...contains only [-0-9.] or other characters as well. I don't think this
> > behaviour is very useful, but I could live with it if only I knew an
> > Erlang function to test for being a number or for being a string. Is
> > there such a function? ....
> 
> You can use guards, e.g:
> 
>   ....
>   case tk:cmd(Entry, [get]) of
>     I when integer(I) ->
>       ....;
>     L when list(L) ->
>       ....
>   end,
>   ....

Another option is to just convert to string if needed, e.g.:
  ...
  String = stringify(tk:cmd(Entry, [get]),
  ...

stringify(N) when integer(N) -> integer_to_list(N);
stringify(N) when list(N)    -> N.




More information about the erlang-questions mailing list