Created
March 14, 2018 12:28
-
-
Save rugheid/5637800841d3dac08e3a12c90815856f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_format(f): | |
line = input().split() | |
tokens = [] | |
for i in range(len(f)): | |
token, line = f[i](line, i == len(f)-1) | |
tokens.append(token) | |
return tokens | |
def _parse_f(f): | |
return lambda words, last: (f(words[0]), words[1:]) | |
getal = _parse_f(int) | |
kommagetal = _parse_f(float) | |
def tekst(words, last): | |
if last: return " ".join(words), [] | |
return words[0], words[1:] | |
i, = read_format([getal]) | |
print(i) | |
j, s = read_format([kommagetal, tekst]) | |
print(j, s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment