Implementing 'curly' and 'access' “chaining” functions in matlab
I read this article on the mathworks blog about functional programming in matlab, and two of the helper functions there were: paren = @(x, varargin) x(varargin{:}); curly = @(x, varargin) x{varargin{:}}; The obvious third one to complete the trio (and in keeping with the five-letter theme) would be: acces = @(x, field) x.(field); Putting the discussion of whether it's a good idea to implement chaining in this manner or not in matlab aside (note: octave supports chaining by default), paren seems to work well, as expected; however, curly and acces have a major drawback; consider the following