more progress

This commit is contained in:
Vítor Santos Costa
2012-11-27 12:10:41 +00:00
parent 6e3f01e0b3
commit e529e79582
9 changed files with 361 additions and 68 deletions

View File

@@ -0,0 +1,17 @@
:- use_module(library(python)).
:- initialization(main).
main :-
ex(X),
flush_output,
fail.
main.
ex(hello_world) :-
c = pyx:canvas:canvas,
:= c:text(0, 0, 'Hello, world!'),
:= c:stroke(path:line(0, 0, 2, 0)),
c.writePDFfile('hello.pdf').

View File

@@ -112,7 +112,7 @@ ex(slices) :-
ex(lists) :-
a := [66.25, 333, 333, 1, 1234.5],
A1 := $a:count(333), A2 := $a:count(66.25), A3 := $a:count('x'),
A1 := $a:count(333), A2 := $a:count(66.25), A3 := $a:count(x),
format('counts=~d ~d ~d~n',[A1,A2,A3]),
:= $a:insert(2, -1),
:= $a:append(333),
@@ -129,3 +129,26 @@ ex(lists) :-
D := $a,
format('a=~w~n', [D]).
ex(iter) :-
it := iter(abc),
format('iter= ', []),
iterate(iter).
iterate(iter) :-
repeat,
( X1 := $it:next,
format('i ~a~n', [X1])
->
fail
;
!
).
ex(range) :-
r1 := range(1000),
r2 := range(1000,2000),
r3 := range(2000,10000,1),
S := sum($r1+ $r2+ $r3),
format('range=~d~n', [S]).