Changeset 4421 for trunk/examples

Show
Ignore:
Timestamp:
08/10/08 10:02:20 (5 months ago)
Author:
pmoura
Message:

Updated the SWI-Prolog and YAP constraint examples with the help of Markus Triska.

Location:
trunk/examples/constraints
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/constraints/swipl/queens.lgt

    r4416 r4421  
    88:- object(queens). 
    99 
    10     :- use_module(clpfd, [ins/2, labeling/2, (#=)/2, (#\=)/2, (#<==>)/2]). 
     10    :- use_module(clpfd, [ins/2, labeling/2, (#=)/2, (#\=)/2, (#<==>)/2, (#>)/2]). 
    1111 
    1212    :- public([n_queens/2, show/3]). 
     
    9797 
    9898    show(N, Options, Qs) :- 
    99         between(1, infinite, N), 
     99        N #> 0, 
     100        n_queens(N, Qs), 
    100101        open(pipe('gs -dNOPAUSE -g680x680 -dGraphicsAlphaBits=2 -r151 -q -'), write, 
    101             Out, [buffer(false),alias(gs)]), 
     102            Out, [buffer(false)]), 
    102103        tell(Out), 
    103104        phrase(postscript, Ps), 
    104         format(Ps), 
    105         format("~w init\n", [N]), 
    106         n_queens(N, Qs), 
    107         call_cleanup(((animate(Qs),labeling(Options, Qs),finish)), close(gs)). 
     105        format("~s\n~w init\n", [Ps, N]), 
     106        call_cleanup(((animate(Qs),labeling(Options, Qs),finish)), close(Out)). 
    108107 
    109108    finish :- 
  • trunk/examples/constraints/swipl/sudoku.lgt

    r4419 r4421  
    9494 
    9595    show(Options, Rows) :- 
    96         open(pipe('gs -dNOPAUSE -g680x680 -dGraphicsAlphaBits=2 -r150 -q -'), write, Out, [buffer(false),alias(gs)]), 
     96        sudoku(Rows), 
     97        open(pipe('gs -dNOPAUSE -g680x680 -dGraphicsAlphaBits=2 -r150 -q -'), write, Out, [buffer(false)]), 
    9798        tell(Out), 
    9899        phrase(postscript, Ps), 
    99100        format(Ps), 
    100         sudoku(Rows), 
    101101        append(Rows, Vs), 
    102         call_cleanup((animate(Rows),labeling(Options, Vs),finish), close(gs)). 
     102        call_cleanup((animate(Rows),labeling(Options, Vs),finish), close(Out)). 
    103103 
    104104    finish :- 
  • trunk/examples/constraints/yap/queens.lgt

    r4418 r4421  
    88:- object(queens). 
    99 
    10     :- use_module(clpfd, [ins/2, labeling/2, (#=)/2, (#\=)/2, (#<==>)/2]). 
     10    :- use_module(clpfd, [ins/2, labeling/2, (#=)/2, (#\=)/2, (#<==>)/2, (#>)/2]). 
    1111    :- use_module(system, [popen/3]). 
    1212 
     
    9898 
    9999    show(N, Options, Qs) :- 
    100         length([_|_], N), 
     100        N #> 0, 
     101        n_queens(N, Qs), 
    101102        popen('gs -dNOPAUSE -g680x680 -dGraphicsAlphaBits=2 -r151 -q -', write, Out), 
    102103        tell(Out), 
    103104        phrase(postscript, Ps), 
    104         format(Ps, []), 
    105         format("~w init\n", [N]), 
    106         n_queens(N, Qs), 
     105        format("~s\n~w init\n", [Ps,N]), 
    107106        call_cleanup(((animate(Qs),labeling(Options, Qs),finish)), close(Out)). 
    108107 
  • trunk/examples/constraints/yap/sudoku.lgt

    r4418 r4421  
    9595 
    9696    show(Options, Rows) :- 
     97        sudoku(Rows), 
    9798        popen('gs -dNOPAUSE -g680x680 -dGraphicsAlphaBits=2 -r150 -q -', write, Out), 
    9899        tell(Out), 
    99100        phrase(postscript, Ps), 
    100101        format(Ps, []), 
    101         sudoku(Rows), 
    102102        append(Rows, Vs), 
    103103        call_cleanup((animate(Rows),labeling(Options, Vs),finish), close(Out)).