[erlang-questions] Updating elements of a record

Donald Steven t6sn7gt@REDACTED
Tue Jan 22 21:10:47 CET 2019

I would like to pass a list of some fields of a record to a function to 
update those fields, leaving the other fields as they were.  The list 
will be different for each function call.  For example, one call might 
want to change fields 1, 2 and 7, another call only field 8, another 
call fields 3 and 4.  Of course, each field will have a unique name.  
Each call to updateStatus (let's call it) would look like  
updateStatus(Status, List_of_Fields_to_Update) -> code.


I can't figure put how to do this economically, without a long 
succession of tests like:

extract fieldnames from list...

case field1name of
         true -> update field1;
         false -> ok % do nothing

repeat for each field...


Any suggestions?

Many thanks.


More information about the erlang-questions mailing list