-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support expressions like [1, *[2, 3], 4]
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
transpiler/src/main/scala/org/polystat/py2eo/transpiler/StarInCollectionConstructor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.polystat.py2eo.transpiler | ||
|
||
import org.polystat.py2eo.parser.Expression.{CollectionCons, Star, T} | ||
|
||
object StarInCollectionConstructor { | ||
def apply(e : T) : T = e match { | ||
case CollectionCons(kind, l, ann) => | ||
val l1 = l.flatMap({ | ||
case Star(CollectionCons(kind1, l, _), _) => l | ||
case x => List(x) | ||
}) | ||
CollectionCons(kind, l1, ann) | ||
case x => x | ||
} | ||
} |