[erlang-questions] ** exception error: no function clause matching test_calculate:validate(["1", "+", "1"], []) (test_calculate.erl, line 11)

Hugo Mills hugo@REDACTED
Wed Sep 30 18:01:18 CEST 2015


On Wed, Sep 30, 2015 at 05:42:20PM +0200, Roelof Wobben wrote:
> Hello,
> 
> I try to make a little parser which parse calculations.
> 
> So so far I have this code :
> 
> -module(test_calculate).
> 
> -export([validate/1]).
> 
> scan(String) ->
>     validate(string:tokens(String, " ")).

   string:tokens/2 expects its first parameter to be a string (i.e. a
list of integers representing the character codes of the elements of
the string).

[snip] 
> test_calculate:validate(["1","+", "1"])

   What is this parameter? Is it what string:tokens/2 is expecting?

   Brief exercise for you: how does erlang represent each of the
following? Write each one as a term without string notation, and as a
string (if it can be written as a string).

[53]
"5"
$5
[$5]

   Hugo.

> I see the above error

   (What error?)

> Someone a tip where things are going the wrong way ?
> 
> Roelof
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-- 
Hugo Mills             | 2 + 2 = 5, for sufficiently large values of 2.
hugo@REDACTED carfax.org.uk |
http://carfax.org.uk/  |
PGP: E2AB1DE4          |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150930/d9e0e97f/attachment.bin>


More information about the erlang-questions mailing list