Prefix string matching

Gaspar Chilingarov <>
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:
> 
> &nbsp; &nbsp; add_prefix&#40;String = "prefix" ++ _&#41; ->
> &nbsp; &nbsp; &nbsp; &nbsp; String;
> &nbsp; &nbsp; add_prefix&#40;Path&#41; ->
> &nbsp; &nbsp; &nbsp; &nbsp; "prefix" ++ String.
> 
> is  equal to:
> 
> &nbsp; &nbsp; add_prefix&#40;String = &#91;$p,$r,$e,$f,$i,$x|_&#93;&#41; ->
> &nbsp; &nbsp; &nbsp; &nbsp; String;
> &nbsp; &nbsp; add_prefix&#40;Path&#41; ->
> &nbsp; &nbsp; &nbsp; &nbsp; "prefix" ++ String.
> 
> 
> Can the compiler optimize:
> 
> &nbsp; &nbsp; "Const" ++ VariableString
> 
> to:
> 
> &nbsp; &nbsp; &#91;$C, $o, $n, $s, $t | VariableString&#93;
> 
> 
> 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 



More information about the erlang-questions mailing list