view general/funutils/@function_handle/with_field.m @ 54:9bcf5e133bf0

Added from old stats library.
author samer
date Mon, 23 Feb 2015 16:08:09 +0000
parents 3cedfd4549ef
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