Giter Club home page Giter Club logo

Comments (3)

andreasabel avatar andreasabel commented on August 15, 2024

Yes, this probably would make sense (if nothing comparable is there).

from agda-stdlib.

mechvel avatar mechvel commented on August 15, 2024

So, I suggest for Standard library (if nothing comparable is there):

foldr-ys++y-eq : ∀ {α β} {A : Set α} {B : Set β} →
  (f : A → B → B) → (x : B) → (y : A) → (ys : List A) →
  foldr f x (ys ∷ʳ y) ≡ foldr f (f y x) ys

foldr-ys++y-eq _ _ _ []       =  PE.refl
foldr-ys++y-eq f x y (z ∷ ys) =  PE.cong (f z) $ foldr-ys++y-eq f x y ys

---

foldl≗foldr∘reverse : ∀ {α β} {A : Set α} {B : Set β} →
                              (f : A → B → B) → (x : B) → (ys : List A) →
                              foldl (flip f) x ys ≡ foldr f x (reverse ys)

foldl≗foldr∘reverse _ _  []       =  PE.refl
foldl≗foldr∘reverse f xs (y ∷ ys) =  
       PE.sym $
       ≡begin
         foldr f xs (reverse (y ∷ ys))      ≡[ PE.cong (foldr f xs)
                                                            rev-yys≡rev-ys++y ]
         foldr f xs ((reverse ys) ∷ʳ y)     ≡[ foldr-ys++y-eq f xs y
                                                                   (reverse ys) ]
         foldr f (f y xs) (reverse ys)       ≡[ PE.sym $ foldl≗foldr∘reverse
                                                                              f (f y xs) ys ]
         foldl ff (f y xs) ys
       ≡end
       where  rev-yys≡rev-ys++y =  unfold-reverse y ys
                   ff = flip f

(the implementation can be changed to something appropriate).

from agda-stdlib.

MatthewDaggitt avatar MatthewDaggitt commented on August 15, 2024

Added in 45c59f4 (named foldr-reverse)

from agda-stdlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.