Skip to content

Commit

Permalink
add ungroup
Browse files Browse the repository at this point in the history
  • Loading branch information
thejaminator committed Jan 16, 2024
1 parent 98a3e81 commit 2079217
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool]
[tool.poetry]
name = "slist"
version = "0.3.1"
version = "0.3.2"
homepage = "https://github.com/thejaminator/slist"
description = "A typesafe list with more method chaining!"
authors = ["James Chua <chuajamessh@gmail.com>"]
Expand Down
5 changes: 5 additions & 0 deletions slist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ def __init__(self, name: str, age: int):
else:
d[k] = Slist([elem])
return Slist(Group(key=key, values=value) for key, value in d.items())


def ungroup(self: Slist[Group[A, B]]) -> Slist[B]:
"""Ungroups the list of groups"""
return self.map_2(lambda _, values: values)

def map_on_group_values(self: Slist[Group[B, Slist[C]]], func: Callable[[Slist[C]], D]) -> Slist[Group[B, D]]:
# Apply a function on the group's vsalues
Expand Down

0 comments on commit 2079217

Please sign in to comment.