view sequences/@seq/diffwith.m @ 3:3f77126f7b5f

First major revision of sequence library, now using classdef form, STILL A BIT BROKEN!
author samer
date Wed, 09 Jan 2013 22:22:21 +0000
parents
children b1280319413e
line wrap: on
line source
function Y=diffwith(F,X)
% diffwith - Generalised diff using argbitrary binary function
%
% diffwith :: (A,A->B), seq A -> seq B.
%
% The given function gets called with the current value as the
% first arguments and the previous value as the second. 

	Y=mapaccum(@diffst,next(X),head(X));
	function [y,s]=diffst(x,s)
		y=F(x,s);
		s=x;
	end
end