samer@4: % cpfields - Copy selected fields from one structure to another samer@4: % samer@4: % cpfields :: samer@4: % C:{[N]->string} ~'fields names to copy', samer@4: % struct A ~'struct with field names in A', samer@4: % struct B ~'struct with field names in B' samer@4: % -> struct union(B,C) ~'struct with fields B union C' :- samer@4: % subset(C,A) ~'target fields must be in A'. samer@4: function B=cpfields(fields,A,B) samer@4: B=foldl(@(b,fn)setfield(b,fn,getfield(A,fn)),B,fields); samer@4: