Skip to content

Commit

Permalink
ogroup
Browse files Browse the repository at this point in the history
  • Loading branch information
molarmanful committed Oct 23, 2023
1 parent 029aeba commit 1344d1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sclin/src/Lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,8 @@ extension (env: ENV)
```
*/
case "group" => group
// TODO: docs
case "~group" => ogroup
/*
@s a f' -> ARR[_ _]'
Equivalent to a combination of #{tk*} and #{dp*}.
Expand Down Expand Up @@ -3019,6 +3021,8 @@ extension (env: ENV)

def group: ENV =
env.mod2((x, y) => y.vec1(f => x.groupBy(SIG_2f1(f), SIG_1f1(f)).toMAP))
def ogroup: ENV =
env.mod2((x, y) => y.vec1(f => x.ogroupBy(SIG_1f1(f)).toOBS))

def span: ENV = env.mod2((x, y) =>
y.vec1(f =>
Expand Down
2 changes: 2 additions & 0 deletions sclin/src/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ enum ANY:
case MAP(x) =>
x.groupBy(f.tupled).view.mapValues(_.toMAP).toMap
case _ => groupBy(g)
def ogroupBy(f: ANY => ANY): Observable[ANY] =
toOBS.x.groupBy(f).map(a => Vector(a.key, a.toOBS).toARR)

def span(f: ANY => Boolean): (ANY, ANY) = this match
case Lsy(x) =>
Expand Down

0 comments on commit 1344d1d

Please sign in to comment.