Skip to content

Commit

Permalink
add GrammaticalExpression.call_on_universe
Browse files Browse the repository at this point in the history
  • Loading branch information
shanest committed Nov 30, 2023
1 parent 82c3cde commit f87d953
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ultk/language/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def evaluate(self, universe: Universe) -> Meaning:
)
return self.meaning

def call_on_universe(self, universe: Universe) -> tuple[Any, ...]:
"""Call this expression on all elements of a universe, and return a tuple of the results."""
return tuple(self(referent) for referent in universe.referents)

def add_child(self, child) -> None:
if self.children is None:
self.children = tuple([child])
Expand Down

0 comments on commit f87d953

Please sign in to comment.