Prefix string matching

Gaspar Chilingarov nm@REDACTED
Fri Jul 28 21:56:36 CEST 2006


Hi andreas!

yes, it's a syntaxic sugar for [ $C, $o, $n, $s, $t | Variable ]


/Gaspar

andreas wrote:
> I wonder if the following expression:
> 
>     add_prefix(String = "prefix" ++ _) ->
>         String;
>     add_prefix(Path) ->
>         "prefix" ++ String.
> 
> is  equal to:
> 
>     add_prefix(String = [$p,$r,$e,$f,$i,$x|_]) ->
>         String;
>     add_prefix(Path) ->
>         "prefix" ++ String.
> 
> 
> Can the compiler optimize:
> 
>     "Const" ++ VariableString
> 
> to:
> 
>     [$C, $o, $n, $s, $t | VariableString]
> 
> 
> If the compiler can not optimize this, how costly is ++ operations in pattern matching?
> 
> 
> Regards,
> Andreas Hillqvist
> _________________________________________________________
> Post sent from http://www.trapexit.org
> 


-- 
Gaspar Chilingarov

System Administrator,
Network security consulting

t +37493 419763 (mob)
i 63174784
e nm@REDACTED



More information about the erlang-questions mailing list