view general/funutils/@function_handle/with_field.m @ 44:3cedfd4549ef

Code added since initial check in.
author samer
date Tue, 13 Jan 2015 14:03:17 +0000
parents
children
line wrap: on
line source
% with_field - Apply operator to structure
% with_field :: 
%     N:string ~'field name',
%     (A->B)   ~'function'
% -> (struct { N : A } -> struct { N : B}).
function g=with_field(nm,f)
	g=@op;
	function x=op(x), x.(nm)=f(x.(nm)); end
end