From 99ae1c838854d8fc1cceaed0d102e7394b3e0ce0 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 8 Nov 2012 21:20:03 +0100 Subject: pd_client: Prepend new choice to history in loop() So that we dont produce a list with an empty list in the initial do-invokation. --- pd_client.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pd_client.pl b/pd_client.pl index 94d1ad5..8aaf93b 100644 --- a/pd_client.pl +++ b/pd_client.pl @@ -11,19 +11,19 @@ start(Module, Host, Port):- launch(Module, StreamIn, StreamOut) :- atom_concat('rules/', Module, Path), consult(Path), - do([], StreamIn, StreamOut, Module, [], []). + do(StreamIn, StreamOut, Module, [], []). % -1 = EOF byte_to_atom(-1, e):-!. byte_to_atom(A, B):-name(B, [A]). -do(e, _, _, _, _, _) :- !. -do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist) :- +do(_, _, _, _, [e|_]) :- !. +do(StreamIn, StreamOut, Module, ModuleState, Hist) :- call(Module, Hist, ModuleDecision, ModuleState, NewModuleState), write(StreamOut, ModuleDecision), flush_output(StreamOut), - loop(StreamIn, StreamOut, Module, NewModuleState, [Choice|Hist]). + loop(StreamIn, StreamOut, Module, NewModuleState, Hist). loop(StreamIn, StreamOut, Module, ModuleState, Hist) :- get_code(StreamIn, ChoiceCode), byte_to_atom(ChoiceCode, Choice), write(Choice), - do(Choice, StreamIn, StreamOut, Module, ModuleState, Hist). + do(StreamIn, StreamOut, Module, ModuleState, [Choice|Hist]). -- cgit