samer@3: function [h,t]=split(dim,n,s) samer@3: % split - gather first n elements and return with rest of sequence samer@3: % samer@3: % split :: D:natural, N:natural, seq A -> [[N]->A], seq A samer@3: samer@3: % !! prevent array growth samer@3: h=[]; samer@3: for i=1:n, x=head(s); h=cat(dim,h,x); s=next(s); end samer@3: t=s; samer@3: samer@3: samer@3: