diff --git a/sclin/src/Lib.scala b/sclin/src/Lib.scala index bfcbb90..f3c91fd 100644 --- a/sclin/src/Lib.scala +++ b/sclin/src/Lib.scala @@ -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*}. @@ -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 => diff --git a/sclin/src/Types.scala b/sclin/src/Types.scala index ed4e9ce..2d24a0f 100644 --- a/sclin/src/Types.scala +++ b/sclin/src/Types.scala @@ -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) =>