view arrows/perm.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 5de03f77dae1
children
line wrap: on
line source
% perm - arrow to permute inputs
%
% perm :: 
%    N:natural ~'number of inputs',
%    P:[[M]->[N]] ~'permutation of inputs'
% -> arrow(_@typelist(N), _@typelist(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