Guest User

Untitled

a guest
Mar 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. def read_format(f):
  2. line = input().split()
  3. tokens = []
  4. for i in range(len(f)):
  5. token, line = f[i](line, i == len(f)-1)
  6. tokens.append(token)
  7. return tokens
  8.  
  9. def _parse_f(f):
  10. return lambda words, last: (f(words[0]), words[1:])
  11.  
  12. getal = _parse_f(int)
  13. kommagetal = _parse_f(float)
  14. def tekst(words, last):
  15. if last: return " ".join(words), []
  16. return words[0], words[1:]
  17.  
  18. i, = read_format([getal])
  19. print(i)
  20. j, s = read_format([kommagetal, tekst])
  21. print(j, s)
Add Comment
Please, Sign In to add comment