Skip to content

Commit

Permalink
make @list.unzip a method (#1444)
Browse files Browse the repository at this point in the history
* make unzip a method

* update mbti

---------

Co-authored-by: Bao Zhiyuan <baozhiyuan@idea.edu.cn>
  • Loading branch information
bzy-debug and Bao Zhiyuan authored Jan 9, 2025
1 parent 6f6bf51 commit 401afd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions immut/list/list.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ pub fn is_empty[A](self : T[A]) -> Bool {
/// assert_eq!(a, @list.from_array([1, 3, 5]))
/// assert_eq!(b, @list.from_array([2, 4, 6]))
/// ```
pub fn unzip[A, B](list : T[(A, B)]) -> (T[A], T[B]) {
match list {
pub fn unzip[A, B](self : T[(A, B)]) -> (T[A], T[B]) {
match self {
Nil => (Nil, Nil)
Cons((x, y), xs) => {
let (xs, ys) = unzip(xs)
Expand Down
3 changes: 1 addition & 2 deletions immut/list/list.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ fn singleton[A](A) -> T[A]

fn unfold[A, S]((S) -> (A, S)?, init~ : S) -> T[A]

fn unzip[A, B](T[(A, B)]) -> (T[A], T[B])

// Types and methods
pub(all) enum T {
Nil
Expand Down Expand Up @@ -87,6 +85,7 @@ impl T {
unsafe_maximum[A : Compare](Self[A]) -> A
unsafe_minimum[A : Compare](Self[A]) -> A
unsafe_nth[A](Self[A], Int) -> A
unzip[A, B](Self[(A, B)]) -> (Self[A], Self[B])
zip[A, B](Self[A], Self[B]) -> Self[(A, B)]?
}
impl[A : Eq] Eq for T[A]
Expand Down

0 comments on commit 401afd2

Please sign in to comment.