Mercurial > hg > ishara
diff arrows/@loop/loop.m @ 0:672052bd81f8
Initial partial import.
author | samer |
---|---|
date | Wed, 19 Dec 2012 22:38:28 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arrows/@loop/loop.m Wed Dec 19 22:38:28 2012 +0000 @@ -0,0 +1,13 @@ +% loop - Looping feedback arrow for stateful arrows. +% +% loop :: +% (A, S -> B, S) ~'function to map input and state to output and next state', +% (size -> S0:S) ~'function to map size of input to initial state' +% -> arrow({A},{B},S) ~'arrow from A to B with state of type S'. + +function o=loop(fn,s0) + if nargin<1, fn=@(a,b)deal(a,b); s0=[]; end + s.fn=fn; s.s0=s0; + o=class(s,'loop',arrow(1,1)); +end +