Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
161be27f
Commit
161be27f
authored
8 years ago
by
Régis Blanc
Browse files
Options
Downloads
Patches
Plain Diff
use preMapWithContext to implement preMap
parent
9215b774
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/leon/purescala/GenTreeOps.scala
+2
-17
2 additions, 17 deletions
src/main/scala/leon/purescala/GenTreeOps.scala
with
2 additions
and
17 deletions
src/main/scala/leon/purescala/GenTreeOps.scala
+
2
−
17
View file @
161be27f
...
@@ -133,23 +133,8 @@ trait GenTreeOps[SubTree <: Tree] {
...
@@ -133,23 +133,8 @@ trait GenTreeOps[SubTree <: Tree] {
* @note The mode with applyRec true can diverge if f is not well formed
* @note The mode with applyRec true can diverge if f is not well formed
*/
*/
def
preMap
(
f
:
SubTree
=>
Option
[
SubTree
],
applyRec
:
Boolean
=
false
)(
e
:
SubTree
)
:
SubTree
=
{
def
preMap
(
f
:
SubTree
=>
Option
[
SubTree
],
applyRec
:
Boolean
=
false
)(
e
:
SubTree
)
:
SubTree
=
{
val
rec
=
preMap
(
f
,
applyRec
)
_
def
g
(
t
:
SubTree
,
u
:
Unit
)
:
(
Option
[
SubTree
],
Unit
)
=
(
f
(
t
),
())
preMapWithContext
[
Unit
](
g
,
applyRec
)(
e
,
())
val
newV
=
if
(
applyRec
)
{
// Apply f as long as it returns Some()
fixpoint
{
e
:
SubTree
=>
f
(
e
)
getOrElse
e
}
(
e
)
}
else
{
f
(
e
)
getOrElse
e
}
val
Deconstructor
(
es
,
builder
)
=
newV
val
newEs
=
es
.
map
(
rec
)
if
((
newEs
zip
es
).
exists
{
case
(
bef
,
aft
)
=>
aft
ne
bef
})
{
builder
(
newEs
).
copiedFrom
(
newV
)
}
else
{
newV
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment