feat: add List.replace
This commit is contained in:
parent
88dc110260
commit
58ddeedced
1 changed files with 6 additions and 0 deletions
|
|
@ -165,6 +165,12 @@ def findSome? (f : α → Option β) : List α → Option β
|
|||
| some b => some b
|
||||
| none => findSome? as
|
||||
|
||||
def replace [HasBeq α] : List α → α → α → List α
|
||||
| [], _, _ => []
|
||||
| a::as, b, c => match a == b with
|
||||
| true => c::as
|
||||
| flase => a :: (replace as b c)
|
||||
|
||||
def elem [HasBeq α] (a : α) : List α → Bool
|
||||
| [] => false
|
||||
| b::bs => match a == b with
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue