Source code on Github
------------------------------------------------------------------------
-- Numerical sums.

{-# OPTIONS --safe #-}
module Prelude.Lists.Sums where

open import Prelude.Init
open Nat using (_≤_; _≤?_; _≥_)
open import Prelude.Bifunctor

private variable
  n : 
  ns : List 
  X Y : Pred  

∑ℕ : List   
∑ℕ = sum

∑⁺ : List⁺   
∑⁺ = ∑ℕ  L.NE.toList

∑₁ : List ( X)  
∑₁ = ∑ℕ  map proj₁


limit : (lim : )
       (∀ {n}  lim  n  X n  Y lim)
       (∀ {n}  n  lim  X n  Y n)
       List ( X)
       List ( Y)
limit {X = X} {Y = Y} l k₁ k₂ = map f
  where
    f :  X   Y
    f (n , x) with l ≤? n
    ... | yes l≤ = l , k₁ l≤ x
    ... | no ¬l≤ = n , k₂ (Nat.≰⇒≥ ¬l≤) x