For Programmers: Free Programming Magazines  


Home > Archive > Prolog > March 2008 > How to output list in a 4x3 format? (swi-prolog)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to output list in a 4x3 format? (swi-prolog)
shaitan00

2008-03-08, 6:28 pm

My prolog application uses a 4x3 board that looks something like this:
Board = A,B,C,D
E,F,G,H
I,J,K,L

This is represented by a list of the form L=[A,B,C,D,E,F,J,H,I,J,K,L].
However when I display the resulting output of L to the user (using write()) I want it to come out looking like a 4x3 instead of either a list or header-by-header.
Currently I am using the following predicate to display/output the results:

code:
%% Display formatted list on 4x3 Puzzle Board State Form report_list([]). report_list([H|T]) :- write(H), nl, report_list(T).


The problem is - as stated - this only outputs one value (header) at a time...
I need to find a way to output L in the 4x3 board format shown above.
Any clues?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com