Mercurial > hg > ishara
annotate sequences/@seq/split_gather.m @ 19:1eb0ea29ec40
Doesn't belong here.
author | samer |
---|---|
date | Thu, 17 Jan 2013 13:32:19 +0000 |
parents | 3f77126f7b5f |
children |
rev | line source |
---|---|
samer@3 | 1 function [h,t]=split(dim,n,s) |
samer@3 | 2 % split - gather first n elements and return with rest of sequence |
samer@3 | 3 % |
samer@3 | 4 % split :: D:natural, N:natural, seq A -> [[N]->A], seq A |
samer@3 | 5 |
samer@3 | 6 % !! prevent array growth |
samer@3 | 7 h=[]; |
samer@3 | 8 for i=1:n, x=head(s); h=cat(dim,h,x); s=next(s); end |
samer@3 | 9 t=s; |
samer@3 | 10 |
samer@3 | 11 |
samer@3 | 12 |