Merge branch 'master' of xato:0517
This commit is contained in:
22
packages/python/examples/multiply.pybk
Normal file
22
packages/python/examples/multiply.pybk
Normal file
@@ -0,0 +1,22 @@
|
||||
i = 5
|
||||
|
||||
def f(arg=i):
|
||||
print arg
|
||||
|
||||
def multiply(a,b):
|
||||
print "Will compute", a, "times", b
|
||||
c = 0
|
||||
for i in range(0, a):
|
||||
c = c + b
|
||||
return c
|
||||
|
||||
def square(a,b):
|
||||
return [a*a,b*b]
|
||||
|
||||
def lsquare(a):
|
||||
print a
|
||||
b = []
|
||||
for i in a:
|
||||
b.append(i*i)
|
||||
return b
|
||||
|
10
packages/python/examples/plot.pybk
Normal file
10
packages/python/examples/plot.pybk
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
:- [library(python)].
|
||||
|
||||
main :-
|
||||
:= import matplotlib.pyplot,
|
||||
:= Plt = ematplotlib.pyplot,
|
||||
Plt.plot([1,2,3,4]),
|
||||
Plt.ylabel(`some numbers`),
|
||||
Plt.show().
|
||||
|
28
packages/python/examples/tests.yap
Normal file
28
packages/python/examples/tests.yap
Normal file
@@ -0,0 +1,28 @@
|
||||
:- use_module(library(python)).
|
||||
:- use_module(library(lists)).
|
||||
|
||||
main :-
|
||||
test(I),
|
||||
catch( dot(I), G, err(I,G) ),
|
||||
writeln('.'),
|
||||
fail.
|
||||
main.
|
||||
|
||||
test(I) :-
|
||||
findall(I, clause(det(I,_,_),_), IsF, Is0 ),
|
||||
Is0 = [],
|
||||
sort(IsF,Is),
|
||||
member(I, Is).
|
||||
|
||||
dot(I) :-
|
||||
det(I, Vs, Sol),
|
||||
Vs == Sol.
|
||||
|
||||
err(I,N) :-
|
||||
format(' test ~d failed with error: ~w',[I,N]).
|
||||
|
||||
|
||||
det(a1,[X],[2]) :- X:=2.
|
||||
det(a2,[],[]) :- x := range(1,10).
|
||||
det(b2 [X],[9]) :- X := x.length().
|
||||
det(c3,[X],[Y]) :- X:=cmath.sin(1), Y is sin(1).
|
Reference in New Issue
Block a user