% perm - arrow to permute inputs
%
% perm :: 
%    N:natural ~'number of inputs',
%    P:[[M]->[N]] ~'permutation of inputs'
% -> arrow(_:arglist(N), _:arglist(M), empty).
%
% This function creates an arrow whos outputs can
% be copies of any of the inputs in any order. 
% For example,
%    perm(5,[3,2,5])
% is an arrow with 5 inputs and 3 outputs. Output
% 1 is input 3, output 2 is input 2, and output 3 is
% input 5.

function a=perm(nin,p)
	nout=length(p);
	a=arr(@permfn,'nargin',nin,'nargout',length(p));

	function varargout=permfn(varargin)
		[varargout{1:nout}]=varargin{p};
	end
end
