1:- module(pkd, []). 2:- use_module(engine). 3term_expansion --> expand_pac.
4
6
7:-bekind(int, []). 8X = `X
9 :- (var(X); integer(X)).
10X + Y = :plus@X@Y.
11X - Y = xargs([A,B,C]:- plus(B,C,A))@X@Y.
12- X = 0 - X.
13:-ekind.
14% ?- listing(int/2).
15%
16% ?- list(([1,2]^3+[4,5]^2)^3, X), length(X, N).
17% ?- list((([1,2]^3+[4,5]^2)^3)^4, X), length(X, N).
18% ?- list([1,2], X).
19% ?- list([1,2]+[3,4], X).
20% ?- eval(list::([1,2]^3), X).
21% ?- eval(int::(1+ -2 + -3 -4), V).
22:-bekind(list, []).
23X = `X
24 :- ( var(X)
25 ; X==[]
26 ; X='[|]'(_,_)
27 ).
28X + Y = :append@X@Y.
29_X ^ 0 = [].
30X ^ N = xargs([A] -> :times(N, A))@ X.
31:-ekind. 32
34
35:- bekind(times//1, []). 360 = `[].
37I = with(H, xargs([X] -> :list(+(H, X))) @
38 @(:flip(succ) @ `I)).
39:- ekind. 40