Erlang/OTP Forums

Author Message

<  Erlang  ~  Function definition efficiency question

jwatte
Posted: Wed Mar 03, 2010 4:07 am Reply with quote
User Joined: 10 Feb 2010 Posts: 34
Is there an efficiency difference between these two implementations? And if there is, any explanation, clarification and depth you can provide would be apprecated.

Code:

min(A, B) when A < B ->
  A;
min(_, B) ->
  B.


min(A, B) ->
  if
    A < B -> A;
    true -> B
  end.

View user's profile Send private message
bpuzon
Posted: Fri Mar 05, 2010 12:05 pm Reply with quote
User Joined: 05 Aug 2009 Posts: 23 Location: Cracow, Poland
I've done some measurements under R13B03 and it seems equal. It's probably compiled to the same bytecode.

_________________
Saludos,
Bartłomiej Puzoń
Erlang Solutions
View user's profile Send private message Visit poster's website
jwatte
Posted: Fri Mar 05, 2010 5:15 pm Reply with quote
User Joined: 10 Feb 2010 Posts: 34
Thanks for your answer! That's good to know.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum