annotate sequences/@seq/diffwith.m @ 16:db7f4afd27c5

Rearranging numerical toolbox.
author samer
date Thu, 17 Jan 2013 13:20:44 +0000
parents 3f77126f7b5f
children b1280319413e
rev   line source
samer@3 1 function Y=diffwith(F,X)
samer@3 2 % diffwith - Generalised diff using argbitrary binary function
samer@3 3 %
samer@3 4 % diffwith :: (A,A->B), seq A -> seq B.
samer@3 5 %
samer@3 6 % The given function gets called with the current value as the
samer@3 7 % first arguments and the previous value as the second.
samer@3 8
samer@3 9 Y=mapaccum(@diffst,next(X),head(X));
samer@3 10 function [y,s]=diffst(x,s)
samer@3 11 y=F(x,s);
samer@3 12 s=x;
samer@3 13 end
samer@3 14 end
samer@3 15