def strided_from
import mlbend-generative@0.1.1.0/main.bend as MlbendGenerativeimport Base
290# Every k-th entry of xs, the (skip+1)-th first: drop `skip`, emit one,
291# drop k-1, emit one, and so on to the end of the list. The list is
292# matched first (binders in order), the skip beside it.
293def strided_from(-A: Data, xs: List<&2, A>, +k: Nat, +skip: Nat) -> List<&2, A>:
294 match xs:
295 case Nil{}:
296 Nil{}
297 case Con{h, t}:
298 match skip:
299 case 0n:
300 Con{h, strided_from(A, t, k, Nat.sub(k, 1n))}
301 case 1n+r:
302 strided_from(A, t, k, r)