-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
097c6ad
commit 6cae10b
Showing
4 changed files
with
152 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
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,31 @@ | ||
from dsn.form_analysis.structure import ( | ||
LambdaForm, | ||
IfForm, | ||
DefineForm, | ||
ApplicationForm, | ||
SequenceForm, | ||
) | ||
|
||
|
||
def general_means_of_collection(form, f, combine, identity): | ||
# Apply thing_to_do on all this form's child (but no lower descendants) forms. | ||
|
||
# The behavior for MalformedForm is TBD; in any case it has no child forms | ||
# VariableForm, ValueForm & QuoteForm have no child-forms | ||
|
||
if isinstance(form, IfForm): | ||
return combine([f(form.predicate), f(form.consequent), f(form.alternative)]) | ||
|
||
if isinstance(form, DefineForm): | ||
return f(form.definition) | ||
|
||
if isinstance(form, LambdaForm): | ||
return combine([f(child) for child in form.body]) | ||
|
||
if isinstance(form, ApplicationForm): | ||
return combine([f(form.procedure)] + [f(child) for child in form.arguments]) | ||
|
||
if isinstance(form, SequenceForm): | ||
return combine([f(child) for child in form.sequence]) | ||
|
||
return identity |