Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rtree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
chrg
rtree
Commits
62740005
Commit
62740005
authored
11 months ago
by
chrg
Browse files
Options
Downloads
Patches
Plain Diff
Final code
parent
8fc081ff
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
pyrtree/expr.py
+7
-7
7 additions, 7 deletions
pyrtree/expr.py
pyrtree/rtree.py
+2
-1
2 additions, 1 deletion
pyrtree/rtree.py
rtree/rtree.cabal
+1
-0
1 addition, 0 deletions
rtree/rtree.cabal
rtree/src/Control/Monad/RTree/Simple.hs
+29
-0
29 additions, 0 deletions
rtree/src/Control/Monad/RTree/Simple.hs
with
39 additions
and
8 deletions
pyrtree/expr.py
+
7
−
7
View file @
62740005
...
...
@@ -111,16 +111,16 @@ def reduce_expr(expr: Expr, check) -> Expr:
return
Const
(
0
)
return
expr
elif
isinstance
(
expr
,
Add
):
if
check
(
"
2) reduce to lhs
"
):
return
reduce_expr
(
expr
.
lhs
,
check
)
if
check
(
"
3) reduce to rhs
"
):
return
reduce_expr
(
expr
.
rhs
,
check
)
lhs_
=
reduce_expr
(
expr
.
lhs
,
check
)
rhs_
=
reduce_expr
(
expr
.
rhs
,
check
)
if
check
(
"
2) reduce to lhs
"
):
return
lhs_
if
check
(
"
3) reduce to rhs
"
):
return
rhs_
return
Add
(
lhs_
,
rhs_
)
elif
isinstance
(
expr
,
Let
):
assignee_
=
reduce_expr
(
expr
.
assignee
,
check
)
if
check
(
"
4) reduce to
lhs
"
):
if
check
(
"
4) reduce to
assingee
"
):
return
assignee_
if
check
(
f
"
5) inline
{
expr
.
var
!r}
"
):
return
reduce_expr
(
expr
.
body
.
replace
({
expr
.
var
:
assignee_
}),
check
)
...
...
@@ -145,7 +145,7 @@ if __name__ == "__main__":
rt
=
partial
(
reduce_expr
,
expr
)
p
(
rtree
.
Probe
(
rt
,
[]))
rp
=
rtree
.
reduce
(
p
,
rt
)
print
(
f
"
&&
{
input_format
(
rp
.
input
)
}
& true
\\\\
"
)
print
(
f
"
&
\\
verb|
{
rtree
.
pretty
(
rp
)
}
|
&
{
input_format
(
rp
.
input
)
}
& true
\\\\
"
)
print
()
...
...
@@ -158,4 +158,4 @@ if __name__ == "__main__":
rt
=
partial
(
reduce_expr
,
expr
)
p
(
rtree
.
Probe
(
rt
,
[]))
rp
=
rtree
.
reduce
(
p
,
rt
)
print
(
f
"
&
{
rtree
.
pretty
{
rp
}
}
&
{
input_format
(
rp
.
input
)
}
& true
\\\\
"
)
print
(
f
"
&
{
rtree
.
pretty
(
rp
)
}
&
{
input_format
(
rp
.
input
)
}
& true
\\\\
"
)
This diff is collapsed.
Click to expand it.
pyrtree/rtree.py
+
2
−
1
View file @
62740005
...
...
@@ -96,7 +96,8 @@ def pretty(rp):
return
"
1
"
if
a
else
"
0
"
return
""
.
join
(
a
for
a
,
_
in
zip_longest
(
map
(
binary
,
rp
.
path
),
rp
.
reasons
,
fillvalue
=
"
*
"
)
a
if
b
!=
"
*
"
else
"
!
"
for
a
,
b
in
zip_longest
(
map
(
binary
,
rp
.
path
),
rp
.
reasons
,
fillvalue
=
"
*
"
)
)
...
...
This diff is collapsed.
Click to expand it.
rtree/rtree.cabal
+
1
−
0
View file @
62740005
...
...
@@ -13,6 +13,7 @@ library
Control.Monad.IRTree
Control.Monad.Reduce
Control.Monad.RTree
Control.Monad.RTree.Simple
Data.RPath
Data.Valuation
other-modules:
...
...
This diff is collapsed.
Click to expand it.
rtree/src/Control/Monad/RTree/Simple.hs
0 → 100644
+
29
−
0
View file @
62740005
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DerivingVia #-}
module
Control.Monad.RTree.Simple
where
import
Control.Monad.Identity
import
Control.Monad.State
type
RTree
a
=
State
([
Bool
],
Int
)
a
check
::
RTree
Bool
check
=
state
\
(
c
:
cs
,
n
)
->
(
c
,
(
cs
,
n
+
1
))
probe
::
RTree
a
->
[
Bool
]
->
(
a
,
Int
)
probe
root
path
=
(
extract
,
depth
-
length
path
)
where
(
extract
,
(
_
,
depth
))
=
runState
root
(
path
++
repeat
False
,
0
)
reduce
::
(
a
->
IO
Bool
)
->
RTree
a
->
[
Bool
]
->
IO
a
reduce
predicate
root
path
|
undecided
>
0
=
do
result
<-
predicate
(
fst
(
probe
root
(
path
++
[
True
])))
reduce
predicate
root
(
path
++
[
result
])
|
otherwise
=
pure
extract
where
(
extract
,
undecided
)
=
probe
root
path
reduceAbc
::
RTree
[
Char
]
reduceAbc
=
filterM
(
\
_
->
check
)
"abc"
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