view general/funutils/@function_handle/with_field.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
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