Mercurial > hg > ishara
diff 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 diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/general/funutils/@function_handle/with_field.m Tue Jan 13 14:03:17 2015 +0000 @@ -0,0 +1,9 @@ +% 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