bug or feature?
Gunilla Arendt
gunilla@REDACTED
Tue Apr 18 13:47:30 CEST 2006
From the reference manual:
6.4.2 String Prefix in Patterns
When matching strings, the following is a valid pattern:
f("prefix" ++ Str) -> ...
This is syntactic sugar for the equivalent, but harder to read
f([$p,$r,$e,$f,$i,$x | Str]) -> ...
Regards, Gunilla
Serge Aleynikov wrote:
> Could anyone explain why matches #5 and #6 below fail? I didn't find in
> documentation a limitation of not being able to specify a variable as
> the first argument of the '++' transform.
>
> Eshell V5.4.13 (abort with ^G)
> (a@REDACTED)1> Prefix = "200".
> "200"
> (a@REDACTED)2> Suffix = "100".
> "100"
> (a@REDACTED)3> "200" ++ "100" = "200100".
> "200100"
> (a@REDACTED)4> "200" ++ Suffix = "200100".
> "200100"
> (a@REDACTED)5> Prefix ++ "100" = "200100".
> ** 1: illegal pattern **
> (a@REDACTED)6> Prefix ++ Suffix = "200100".
> ** 1: illegal pattern **
> (a@REDACTED)7> Prefix ++ Suffix.
> "200100"
> (a@REDACTED)9> "200" ++ Suffix = v(7).
> "200100"
>
> Regards,
>
> Serge
>
>
More information about the erlang-questions
mailing list