Erlang workshop and user conference

Vlad Dumitrescu vladdu@REDACTED
Wed Oct 3 09:56:47 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}.

>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}.

Hi,

Just a 2 beans thought... Wouldn't it be even nicer to read and easier to understand if one could add some syntactic sugar and be able to specify types not as

fun(X, {Y, Z}) when integer(X), list(Z) -> ...

but as (for example)

fun (X/integer, {Y, Z/list}) -> ...  ?

regards, Vlad



More information about the erlang-questions mailing list