annotate arrows/perm.m @ 6:0ce3c2070089
Removed duplicate code and fixed doc in timed_action.
author |
samer |
date |
Mon, 14 Jan 2013 14:33:37 +0000 |
parents |
672052bd81f8 |
children |
5de03f77dae1 |
rev |
line source |
samer@0
|
1 % perm - arrow to permute inputs
|
samer@0
|
2 %
|
samer@0
|
3 % perm ::
|
samer@0
|
4 % N:natural ~'number of inputs',
|
samer@0
|
5 % P:[[M]->[N]] ~'permutation of inputs'
|
samer@0
|
6 % -> arrow(_:arglist(N), _:arglist(M), empty).
|
samer@0
|
7 %
|
samer@0
|
8 % This function creates an arrow whos outputs can
|
samer@0
|
9 % be copies of any of the inputs in any order.
|
samer@0
|
10 % For example,
|
samer@0
|
11 % perm(5,[3,2,5])
|
samer@0
|
12 % is an arrow with 5 inputs and 3 outputs. Output
|
samer@0
|
13 % 1 is input 3, output 2 is input 2, and output 3 is
|
samer@0
|
14 % input 5.
|
samer@0
|
15
|
samer@0
|
16 function a=perm(nin,p)
|
samer@0
|
17 nout=length(p);
|
samer@0
|
18 a=arr(@permfn,'nargin',nin,'nargout',length(p));
|
samer@0
|
19
|
samer@0
|
20 function varargout=permfn(varargin)
|
samer@0
|
21 [varargout{1:nout}]=varargin{p};
|
samer@0
|
22 end
|
samer@0
|
23 end
|