Prefix string matching
andreas
andreas@REDACTED
Fri Jul 28 19:11:18 CEST 2006
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
More information about the erlang-questions
mailing list