Mercurial > hg > ishara
diff sequences/dropwhile.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/sequences/dropwhile.m Wed Dec 19 22:38:28 2012 +0000 @@ -0,0 +1,14 @@ +function s=dropwhile(f,s) +% drop - Drop elements of sequence that satisfy condition +% +% drop :: (A->bool), seq A -> seq A + +% if isempty(s) return s; end +x=head(s); +while f(x), + s=next(s); + if isempty(s), break; end + x=head(s); +end + +