samer@0: % perm - arrow to permute inputs samer@0: % samer@0: % perm :: samer@0: % N:natural ~'number of inputs', samer@0: % P:[[M]->[N]] ~'permutation of inputs' samer@27: % -> arrow(_@typelist(N), _@typelist(M), empty). samer@0: % samer@0: % This function creates an arrow whos outputs can samer@0: % be copies of any of the inputs in any order. samer@0: % For example, samer@0: % perm(5,[3,2,5]) samer@0: % is an arrow with 5 inputs and 3 outputs. Output samer@0: % 1 is input 3, output 2 is input 2, and output 3 is samer@0: % input 5. samer@0: samer@0: function a=perm(nin,p) samer@0: nout=length(p); samer@0: a=arr(@permfn,'nargin',nin,'nargout',length(p)); samer@0: samer@0: function varargout=permfn(varargin) samer@0: [varargout{1:nout}]=varargin{p}; samer@0: end samer@0: end