Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e50ffe2

Browse files
committed
improve repr
1 parent 0fa49e1 commit e50ffe2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎code.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
CAR = lambda p: p(TRUE)
5151
CDR = lambda p: p(FALSE)
5252

53+
# The Billion Dollar Mistake
54+
NULL = lambda _: TRUE
55+
ISNULL = lambda _: lambda _: FALSE
56+
57+
# signed numbers
58+
SIGN = lambda n: CONS(n)(0)
59+
NEG = lambda p: CONS(CDR(p))(CAR(p))
60+
ISPOS = lambda p: GT(CAR(p))(0)
61+
ISNEG = lambda p: GT(CDR(p))(0)
62+
UNSIGN = lambda p: SUB(CAR(p))(CDR(p))
5363

5464
# recursive
5565
FAC = Y(
@@ -77,3 +87,8 @@
7787
def make_number(f) -> int:
7888
incr = lambda x: x + 1
7989
return f(incr)(0)
90+
91+
92+
# improve repr
93+
for name, func in locals().items():
94+
func.__qualname__ = name

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /