def conns.cut

bend-kit-postgres@0.3.0.0 · postgres.bend:623

import bend-kit-postgres@0.3.0.0/postgres.bend as Postgres
import Base

623# The first n connections; the rest are closed.
624def conns.cut(xs: List<&1, Conn>, n: Nat) -> IO(List<&1, Conn>):
625  match xs:
626    case Nil{}:
627      IO.pure(List<&1, Conn>, Nil{})
628    case Con{c, t}:
629      match n:
630        case 0n:
631          do IO<List<&1, Conn>>:
632            close(c)
633            conns.cut(t, 0n)
634        case 1n+k:
635          do IO<List<&1, Conn>>:
636            r : List<&1, Conn> <- conns.cut(t, k)
637            return c <> r

Uses (8)

Used by (2)