Mercurial > hg > ishara
view general/map_fields.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
% map_fields - Apply function to all member fields of structure % % map_fields :: % (A->B) ~'function from As to Bs', % struct(fields(N,A)) % -> struct(fields(N,B)). % % fields(N,A) denotes a list of struct field type declarates with % names from list N and types all equal to A, eg % fields({'a','b','c'},real) == {a::real, b::real, c::real}. function y=map_fields(fn,x) y=foldl(@(s,f)setfield(s,f,fn(s.(f))),x,fields(x));