def conns.cut
import bend-kit-redis@0.3.0.0/redis.bend as Redisimport Base
1018# The first n connections; the rest are closed.
1019def conns.cut(xs: List<&1, Conn>, n: Nat) -> IO(List<&1, Conn>):
1020 match xs:
1021 case Nil{}:
1022 IO.pure(List<&1, Conn>, Nil{})
1023 case Con{c, t}:
1024 match n:
1025 case 0n:
1026 do IO<List<&1, Conn>>:
1027 close(c)
1028 conns.cut(t, 0n)
1029 case 1n+k:
1030 do IO<List<&1, Conn>>:
1031 r : List<&1, Conn> <- conns.cut(t, k)
1032 return c <> r