\\ 1 if all elements of v belong to A). t_allbelong (v,A) = t_all(x->t_pos(x,A),v) \\ Longest run of subvector u in v. t_longrun (u,v) = {my (k=0); for (i=1,#v-#u+1, k=max(k,t_posmultvec(u,v,i))); k} \\ Number of (overlapping) occurrences of u in v. t_multvec (u,v) = {my (m,n,f); m=#u; n=#v; f=0; for (i=1,n-m+1, f+=(v[i..i+m-1]==u)); f} \\ Position of first x as element in v from index k. 0 if not present. \\ Works also if v is a string. t_ pos (x,v,k=1) = {v=Vec(v); for (i=k,#v, if (v[i]==x, return(i))); 0} \\ Vector of all appearances of elements of X in v, \\ beginning from position k. Works also for strings v. t_posall (X,v,k=1) = {my (p,i); v=Vec(v); p=[]; for (i=k,#v, if (t_pos(v[i],X), p=concat(p,[i]))); p} \\ k if u appears k times as subvector in v at position i. t_posmultvec (u,v,i) = {my (m=#u,k,j); k=0; j=i+m-1; while (j<=#v, if (t_repvec(u,k+1)==v[i..j], k++; j+=m, break)); k} \\ Position of first u as subvector in v from index k. 0 if not present. t_posvec (u,v,k=1) = {my (m=#u); if (m>#v, return(0)); for (i=k,#v-m+1, if (v[i..i+m-1]==u, return (i))); 0} \\ Vector of blocks [a,a+1,a+2,...] in v. t_progressiveblocks (v) = {my (n,u,x,y,b); n=#v; if (!n, return([]), n==1, return([[v[1]]])); u=[]; y=v[1]; b=[y]; for (i=2,n,x=v[i]; if (x==y+1, b=concat(b,[x]),\ u=concat(u,[b]); b=[x]); y=x); concat(u,[b])}