view sequences/+seq/mapper.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 9e7be347b3a0
children
line wrap: on
line source
% 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