{-# OPTIONS --with-K #-}
module README.Function.Reasoning where
open import Function.Reasoning
module _ {A B C : Set} {A→B : A → B} {B→C : B → C} where
A→C : A → C
A→C a =
a ∶ A
|> A→B ∶ B
|> B→C ∶ C
open import Data.Nat
open import Data.List.Base
open import Data.Char.Base
open import Data.String.Base as String using (String; toList; fromList)
open import Data.String.Properties as String using (_==_)
open import Function.Base using (_∘_)
open import Data.Bool hiding (_≤?_)
open import Data.Product.Base as P using (_×_; <_,_>; uncurry; proj₁)
open import Agda.Builtin.Equality
subpalindromes : String → List String
subpalindromes str = let Chars = List Char in
str ∶ String
|> toList ∶ Chars
|> inits ∶ List Chars
|> concatMap tails ∶ List Chars
|> filter (λ cs → 2 ≤? length cs) ∶ List Chars
|> map < fromList , fromList ∘ reverse > ∶ List (String × String)
|> filter (uncurry String._≟_) ∶ List (String × String)
|> map proj₁ ∶ List String
_ : subpalindromes "doctoresreverse" ≡ "eve" ∷ "rever" ∷ "srevers" ∷ "esreverse" ∷ []
_ = refl
_ : subpalindromes "elle-meme" ≡ "ll" ∷ "elle" ∷ "mem" ∷ "eme" ∷ []
_ = refl