translate_to_table(A,RowNr,[list(L)],Header,Opts) :- var(A),!,
(member('no-row-numbers',Opts) -> set_header(Header,['Value']),L=AT
; set_header(Header,['Nr','Value']),L=[RowNr|AT]),
translate:translate:translate_bvalue(A,AT).
translate_to_table([],_RowNr,[],Header,Opts) :- !,
(ground(Header) -> true % we already have a header
; member('no-row-numbers',Opts) -> set_header(Header,['Elements']) ; set_header(Header,['Nr','Elements'])).
translate_to_table([A|T],RowNr,[list(LA)|TT],Header,Opts) :- member('no-row-numbers',Opts),
!,
get_table_entry(A,LA,Header,Opts),
R1 is RowNr+1,
translate_to_table(T,R1,TT,_,Opts).
translate_to_table([A|T],RowNr,[list([RowNr|LA])|TT],['Nr'|Header],Opts) :- !,
get_table_entry(A,LA,Header,Opts),
R1 is RowNr+1,
translate_to_table(T,R1,TT,_,Opts).
translate_to_table(A,_RowNr,[list(AT)],['Value'],Opts) :- member('no-row-numbers',Opts),!,
translate:translate:translate_bvalue(A,AT).
translate_to_table(A,RowNr,[list([RowNr|AT])],Header,_) :- !,
set_header(Header,['Nr','Value']),
translate:translate:translate_bvalue(A,AT).
translate_to_table(ExpVal,Row,Table,Header,Opts) :-
add_internal_error('Failed:',translate_to_table(ExpVal,Row,Table,Header,Opts)),fail.