[erlang-questions] Match the records

Matwey V. Kornilov matwey.kornilov@REDACTED
Tue Jan 12 14:46:14 CET 2016


Hello,

I have the record definition with a lot of fields, so it is pretty long 
record.

-record(myrec, {f0, f1, f2, f3, .....}).

Let X and Y be two records of this type.
I can not understand how should I do the following pattern matching.

I want all fields of X and Y be the same, except f0, and f0 should be 
bound to new variable F. As there are a lot of fields I don't want to 
explicitly enumerate them in my code in order DRY.

In other words I need a short form of:
#myrec{f0 = F, f1 = X#myrec.f1, ...} = Y.




More information about the erlang-questions mailing list