Prolog Text thread

/**
 * Prolog code for the multi threading tour.
 *
 * Copyright 2010, XLOG Technologies GmbH, Switzerland
 * Jekejeke Prolog 0.8.7 (a fast and small prolog interpreter)
 */

init :- current_output(X), assertz(console(X)).

log(X,Y) :-
    atom_concat('Process ',X,A1),
    atom_concat(A1,': ',A2),
    atom_concat(A2,Y,A3),
    atom_concat(A3,'\n',A4),
    console(Z),
    write(Z,A4),
    flush_output(Z).

process(X) :-
    repeat,
    log(X,'Ha'),
    log(X,'Tschi'),
    fail.

Comments