Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Frontull Samuel
alpha
Commits
7b4c4de1
Commit
7b4c4de1
authored
Aug 08, 2021
by
Frontull Samuel
Browse files
reduce with combinators
parent
6cbb5564
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
pcp/lambda.hs
pcp/lambda.hs
+11
-7
No files found.
pcp/lambda.hs
View file @
7b4c4de1
...
@@ -120,21 +120,25 @@ churchNum _ = Nothing
...
@@ -120,21 +120,25 @@ churchNum _ = Nothing
isChurchNum
t
=
churchNum
t
/=
Nothing
isChurchNum
t
=
churchNum
t
/=
Nothing
beta
::
Term
->
Term
beta
(
App
(
Abs
x
t
)
u
)
=
subst
x
u
t
beta
x
=
x
betastep
::
Term
->
Term
betastep
::
Term
->
Term
betastep
(
Var
x
)
=
Var
x
betastep
(
Abs
x
t
)
=
Abs
x
(
betastep
t
)
betastep
(
Abs
x
t
)
=
Abs
x
(
betastep
t
)
betastep
(
App
(
Abs
x
e1
)
e2
)
=
beta
(
App
(
Abs
x
e1
)
e2
)
betastep
(
App
(
Abs
x
e1
)
e2
)
=
subst
x
e2
e1
betastep
(
App
I
e1
)
=
e1
betastep
(
App
(
App
K
e1
)
e2
)
=
e1
betastep
(
App
(
App
(
App
S
e1
)
e2
)
e3
)
=
(
App
(
App
e1
e3
)
(
App
e2
e3
))
betastep
(
App
e1
e2
)
=
betastep
(
App
e1
e2
)
=
let
left
=
betastep
e1
in
let
left
=
betastep
e1
in
if
left
==
e1
then
App
e1
(
betastep
e2
)
if
left
==
e1
then
App
e1
(
betastep
e2
)
else
App
left
e2
else
App
left
e2
betastep
x
=
x
betastep
x
=
x
nf
::
Term
->
Term
nf
::
Term
->
Int
->
Term
nf
term
=
if
(
betastep
term
)
==
term
then
term
else
nf
(
betastep
term
)
nf
term
i
=
let
new
=
betastep
term
in
if
i
>
0
then
if
new
==
term
then
term
else
nf
new
(
i
-
1
)
else
new
-- data SKITerm = S | K | I | CA SKITerm SKITerm
-- data SKITerm = S | K | I | CA SKITerm SKITerm
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment