:- set_prolog_flag( update_semantics, logical ). get_single_char( C ) :- get0( C ). get_line( Cs ) :- get0( C ), ( C == 10 -> % end of line Cs = [] ; Cs = [C|Tcs], get_line( Tcs ) ). nth1( A,B,C ) :- nth( A,B,C ). nth1( A,B,C,D ) :- nth( A,B,C,D ).