ProjectEuler 2, nearly (#125)

This commit is contained in:
Patrick Stevens
2020-04-19 13:40:22 +01:00
committed by GitHub
parent e660eceb43
commit 485b27e009
11 changed files with 751 additions and 488 deletions

View File

@@ -83,3 +83,11 @@ Sequence.tail (subsequence x selector increasing) = subsequence (tailFrom (succ
take : {a : _} {A : Set a} (n : ) (s : Sequence A) Vec A n
take zero s = []
take (succ n) s = Sequence.head s ,- take n (Sequence.tail s)
unfold : {a : _} {A : Set a} (A A) A Sequence A
Sequence.head (unfold f a) = a
Sequence.tail (unfold f a) = unfold f (f a)
indexAndUnfold : {a : _} {A : Set a} (f : A A) (start : A) (n : ) index (unfold f start) (succ n) f (index (unfold f start) n)
indexAndUnfold f s zero = refl
indexAndUnfold f s (succ n) = indexAndUnfold f (f s) n