Skip to content

Commit

Permalink
Merge filter/map into mapMulti
Browse files Browse the repository at this point in the history
  • Loading branch information
Thihup committed Oct 1, 2024
1 parent f0b74e5 commit 92c943c
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@ public ExpressionNode visitIdOrArray(VisuAlgParser.IdOrArrayContext ctx) {
return ctx.children
.stream()
.map(this::visit)
.filter(x -> x instanceof ExpressionNode)
.map(x -> (ExpressionNode) x)
.<ExpressionNode>mapMulti((node, consumer) -> {
if (node instanceof ExpressionNode expressionNode) {
consumer.accept(expressionNode);
}
})
.reduce((result, element) -> switch (element) {
case ArrayAccessNode(_, CompundNode<ExpressionNode> indexes, var location) ->
new ArrayAccessNode(result, indexes, location);
Expand Down

0 comments on commit 92c943c

Please sign in to comment.