comparison general/funutils/@function_handle/and.m @ 39:c388f1c70669

Updated documentation and fixed some bugs in function algebra
author samer
date Tue, 29 Jan 2013 17:02:00 +0000
parents 9d24b616bb06
children ae596261e75f
comparison
equal deleted inserted replaced
38:9d24b616bb06 39:c388f1c70669
1 % and - function combinator, f&g (...) = f(...); return g(...) 1 % and - sequential call function combinator
2 % 2 %
3 % and :: 3 % and ::
4 % (A{:} => B{:}), 4 % (A{:} => B{:}),
5 % (A{:} => C{:}) 5 % (A{:} => C{:})
6 % -> (A{:} => C{:}). 6 % -> (A{:} => C{:}).
7 % 7 %
8 % and :: 8 % and ::
9 % (A{1:N} => B{:}), 9 % (A{:} => B{:}),
10 % (A{1:N} => C{1:M}), 10 % (A{:} => C{:}),
11 % N:natural, 11 % N:natural,
12 % M:natural 12 % M:natural
13 % -> (A{1:N} => C{1:M}). 13 % -> (A{1:N} => C{1:M}).
14 %
15 % f&g == and(f,g) is a function which first calls f with given arguments,
16 % discarding return values, then calls g with arguments returning result.
14 function h=and(f,g,nin,nout) 17 function h=and(f,g,nin,nout)
15 if nargin<4, nout=nargout(g); end 18 if nargin<4, nout=nargout(g); end
16 if nargin<3, nin=nargin(g); end 19 if nargin<3, nin=nargin(g); end
17 fns = { @q11, @q1n; @qn1, @qnn }; 20 fns = { @q11, @q1n; @qn1, @qnn };
18 h=fns{acount(nin,1),acount(nout,1)}; 21 h=fns{acount(nin,1),acount(nout,1)};