% mapper - seq where values is a stateless function of another sequence
%
% mapper :: (A->B), seq(A) -> seq(B).
classdef mapper < seq
	properties (GetAccess=public, SetAccess=private)
		fn
		source
	end
	methods
		function d=mapper(fn,source,varargin)
			d.fn=fn; 	
			d.source=source;
		end

		function s=tostring(d), s=sprintf('%s >> %s',tostring(d.source),tostring(d.fn)); end;
		function x=head(d), x=d.fn(head(d.source)); end
		function s=elsize(d), s=size(head(d)); end
		function d=next(d), d.source=next(d.source); if isempty(d.source), d=nil; end; end
	end
end
