Skip to content

sum and product for lists #1298

Closed
Closed
@mechvel

Description

@mechvel

Data.List.Base has sum and product for lists over Nat.

Probably it is better to replace this with a generic design:

module Algebra.Properties.Monoid  ... where
C = Carrier

Π₁ : C → List C → C   -- product of a nonempty list of elements                 
Π₁ x = foldr _∙_ x                                                              
                                                                                  
Π : List C → C         -- product of a list of elements                
Π = Π₁ ε                                                                        
    
----------------------------------------
module Algebra.Properties.Semiring ... where
...
sum1 : C → List C → C                                                           
sum1 = Algebra.Properties.Monoid.Π₁  +-0-monoid                                                            
                                                                                  
sum : List C → C                       
sum = Algebra.Properties.Monoid.Π  +-0-monoid 

with adding to Algebra.Properties the needed modules for Monoid and Semiring.

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: duplicateThe main contents of the issue or PR already exists in another issue or PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions