Question

I'm going through "Pragmatic Programming Erlang" where there is a function defined like this:

split("\r\n\r\n" ++ T, L) -> {reverse(L), T};
split([H|T], L) -> split(T, [H|L]);
split([], _) -> more.

What interests me is first match, namely "\r\n\r\n" ++ T - is there performance difference between such a pattern and similar one, that I came up with: [13,10,13,10|T]? Or are they equivalent?

I know it's very simple question and that I could (probably) check it myself, but if there is a difference, I'd like to know why that is the case.

Thanks!

Était-ce utile?

La solution

"\r\n\r\n" ++ T is just syntax sugar for [13,10,13,10|T]. It should perform same. If not there is something wrong ;-)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top