mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-19 01:01:59 +03:00
refactor(base): move implementation of Data.Vect.nubBy
to global scope
Closes #3285
This commit is contained in:
parent
bcf8598f99
commit
2c128e216c
@ -144,6 +144,9 @@ This CHANGELOG describes the merged but unreleased changes. Please see [CHANGELO
|
|||||||
* Added `funExt0` and `funExt1`, functions analogous to `funExt` but for functions
|
* Added `funExt0` and `funExt1`, functions analogous to `funExt` but for functions
|
||||||
with quantities 0 and 1 respectively.
|
with quantities 0 and 1 respectively.
|
||||||
|
|
||||||
|
* Moved definition of `Data.Vect.nubBy` to the global scope as `nubByImpl` to
|
||||||
|
allow compile time proofs on `nubBy` and `nub`.
|
||||||
|
|
||||||
#### Contrib
|
#### Contrib
|
||||||
|
|
||||||
* `Data.List.Lazy` was moved from `contrib` to `base`.
|
* `Data.List.Lazy` was moved from `contrib` to `base`.
|
||||||
|
@ -76,6 +76,7 @@ Thomas E. Hansen
|
|||||||
Tim Süberkrüb
|
Tim Süberkrüb
|
||||||
Timmy Jose
|
Timmy Jose
|
||||||
Tom Harley
|
Tom Harley
|
||||||
|
troiganto
|
||||||
Wen Kokke
|
Wen Kokke
|
||||||
Wind Wong
|
Wind Wong
|
||||||
Zoe Stafford
|
Zoe Stafford
|
||||||
|
@ -662,6 +662,14 @@ filter p (x::xs) =
|
|||||||
else
|
else
|
||||||
(_ ** tail)
|
(_ ** tail)
|
||||||
|
|
||||||
|
public export
|
||||||
|
nubByImpl : Vect m elem -> (elem -> elem -> Bool) -> Vect len elem -> (p ** Vect p elem)
|
||||||
|
nubByImpl acc p [] = (_ ** [])
|
||||||
|
nubByImpl acc p (x::xs) with (elemBy p x acc)
|
||||||
|
nubByImpl acc p (x :: xs) | True = nubByImpl acc p xs
|
||||||
|
nubByImpl acc p (x :: xs) | False with (nubByImpl (x::acc) p xs)
|
||||||
|
nubByImpl acc p (x :: xs) | False | (_ ** tail) = (_ ** x::tail)
|
||||||
|
|
||||||
||| Make the elements of some vector unique by some test
|
||| Make the elements of some vector unique by some test
|
||||||
|||
|
|||
|
||||||
||| ```idris example
|
||| ```idris example
|
||||||
@ -669,14 +677,7 @@ filter p (x::xs) =
|
|||||||
||| ```
|
||| ```
|
||||||
public export
|
public export
|
||||||
nubBy : (elem -> elem -> Bool) -> Vect len elem -> (p ** Vect p elem)
|
nubBy : (elem -> elem -> Bool) -> Vect len elem -> (p ** Vect p elem)
|
||||||
nubBy = nubBy' []
|
nubBy = nubByImpl []
|
||||||
where
|
|
||||||
nubBy' : forall len . Vect m elem -> (elem -> elem -> Bool) -> Vect len elem -> (p ** Vect p elem)
|
|
||||||
nubBy' acc p [] = (_ ** [])
|
|
||||||
nubBy' acc p (x::xs) with (elemBy p x acc)
|
|
||||||
nubBy' acc p (x :: xs) | True = nubBy' acc p xs
|
|
||||||
nubBy' acc p (x :: xs) | False with (nubBy' (x::acc) p xs)
|
|
||||||
nubBy' acc p (x :: xs) | False | (_ ** tail) = (_ ** x::tail)
|
|
||||||
|
|
||||||
||| Make the elements of some vector unique by the default Boolean equality
|
||| Make the elements of some vector unique by the default Boolean equality
|
||||||
|||
|
|||
|
||||||
|
Loading…
Reference in New Issue
Block a user