fork download
  1. printl_list([H|X]):-
  2. put_code(H), printl_list(X).
  3.  
  4. read_line_codes(A, L) :-
  5. get_code(C),
  6. ( C == -1
  7. -> ( A == []
  8. -> L = end_of_file
  9. ; reverse(A, L)
  10. )
  11. ; ( C == 0'\n
  12. -> reverse(A, L)
  13. ; read_line_codes([C|A], L)
  14. )
  15. ).
  16.  
  17. :- initialization(main).
  18. main :-
  19. repeat,
  20. read_line_codes([], X),
  21. (X == [52,50]
  22. -> (
  23. halt
  24. )
  25. ; (
  26. nl,
  27. printl_list(X)
  28. )),
  29. X == end_of_file,
  30. halt.
Success #stdin #stdout 0.01s 5320KB
stdin
1
2
10
42
11
stdout
1
2
10