Erlang workshop and user conference

James Hague jamesh@REDACTED
Tue Oct 2 20:33:03 CEST 2001


> > cross({V10,V11,V12}, {V20,V21,V22}) when float(V10), 
> >    float(V11), float(V12), float(V20), float(V21),
> >    float(V22) ->
> >     {V11*V22-V12*V21,V12*V20-V10*V22,V10*V21-V11*V20}.
> 
> I love the speed improvements, but that sure is _verbose_.

Better:

-define(floats(X,Y,Z), float(X), float(Y), float(Z)).

cross({V10,V11,V12}, {V20,V21,V22})
   when ?floats(V10,V11,V12), ?floats(V20,V21,V22) ->
   {V11*V22-V12*V21,V12*V20-V10*V22,V10*V21-V11*V20}.


Now we just need cross added to the math module and implemented in C :)

James



More information about the erlang-questions mailing list