From b08c087aaf759ac4d3c77480e0d05852c3b153dc Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Tue, 5 Jan 2021 16:05:18 +0900 Subject: [PATCH] exit at EOF (python-version) --- others/planck.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/others/planck.py b/others/planck.py index 756e6b3..0345ede 100644 --- a/others/planck.py +++ b/others/planck.py @@ -137,7 +137,13 @@ add_simple_operator('Q', lambda: exit(0)) add_simple_operator('C', lambda: push(CELL)) add_simple_operator('h', lambda: push(HERE_CELL)) add_simple_operator('l', lambda: push(LATEST_CELL)) -add_simple_operator('k', lambda: push(ord(sys.stdin.read(1)))) +def key(): + c = sys.stdin.read(1) + if c: + push(ord(c)) + else: + exit(0) +add_simple_operator('k', key) add_simple_operator('t', lambda: sys.stdout.write(chr(pop()))) add_operator('j', lambda ip,np: next(np + read(np))) add_operator('J', lambda ip,np: next(np + (CELL if pop() else read(np))))