Example 14: Progressive Plotting

Introduction

Non Blocking

:- ensure_loaded(library(misc/markup)).
:- ensure_loaded(library(misc/react)).

run :-
   tag('<button>'),
   bind('click', E, test(E)),
   write('click'),
   tag('</button>').

test(E) :-
   ir_object_current(E, 'target', T),
   dom_output_new(T, D),
   write(D, ' and again'),
   close(D).

:- run.

Non Progressive

:- ensure_loaded(library(tester/plot)).

test :-
   findall([X,Y], (between(0,180,K), W is pi*K/90,
       X is sin(2*W), Y is cos(3*W)), L),
   plot(L,[mark('')]).

:- test.

Blocking

run2 :-
   tag('<button id="emitter">'),
   write('click'),
   tag('</button>'),
   loop.

loop :-
   goto('emitter'),
   repeat,
   listen('click', _, true, [block(true)]),
   write(' and again'),
   flush_output,
   fail.

:- run2.

Progressive

test2 :-
   plot_begin([mark('')]),
   (between(0,180,J),
      I is J-10,
      findall([X,Y], (between(I,J,K), W is pi*K/90,
         X is sin(2*W), Y is cos(3*W)), L),
      clear,
      plot_add(L, [mark('')]),
      flush_output, sleep(10), fail; true),
   plot_end.

:- test2.

Conclusions