view sequences/slices.m @ 29:61921dceded1

More documentation on type system.
author samer
date Sat, 19 Jan 2013 17:56:21 +0000
parents b1280319413e
children 9e7be347b3a0
line wrap: on
line source
% slices - sequence obtained from slices of an array
%
% slices :: 
%    [[Size,M]->A]	~'array to slices',
% -> seq([[Size]->A]).
%
% slices :: 
%    [Size->A]	~'array to slices',
%    D:natural ~'dimension of desired values'
% -> seq([Size:[[1,D]]->A]).
%
% If 2nd parameter not given, the array is sliced along it's
% last non-singleton dimension, so the element size is the size
% after this dimension has been removed. If given, the dimension
% parameter cannot be smaller than the number of non-singleton
% dimensions in the input.

function y=slices(x,dim), 
	if nargin<2, dim=length(size(x))-1; end
	if isempty(x), y=nil; else y=seq.slices(x,dim); end
end