-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1035956
commit cd0f00c
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/- | ||
# Problem 20 | ||
Remove the K'th element from a list. | ||
-/ | ||
variable {α : Type} | ||
|
||
def removeAt (l : List α) (n : Nat) : List α := | ||
-- sorry | ||
match l,n with | ||
| [] , _ => [] | ||
| _ , 0 => l | ||
| x :: b , m + 2 => x :: removeAt b (m+1) | ||
| _ :: b , _ => b | ||
-- sorry | ||
|
||
-- The following code is a test case and you should not change it. | ||
example : removeAt ['a','b','c','d'] 2 = ['a','c','d'] := rfl | ||
|
||
example : removeAt ['a','b','c','d'] 5 = ['a','b','c','d'] := rfl | ||
|
||
example : removeAt ['a','b','c','d'] 0 = ['a','b','c','d'] := rfl | ||
|
||
example : removeAt ['a'] 1 = [] := rfl | ||
|
||
example : removeAt ([] : List α) 1 = [] := rfl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters