init: first commit

This commit is contained in:
Renge 2024-02-19 23:38:00 -05:00
commit c0b878e8ef
5 changed files with 50 additions and 0 deletions

15
A/append.P Normal file
View File

@ -0,0 +1,15 @@
append([],Ys,Ys).
append([X|Xs],Ys,[X|Zs]) :- append(Xs,Ys,Zs).
suffix(Xs, Ys) :-
append(Xs, Suffix, Ys),
write(Suffix).
cut(Zs) :-
findall([Xs,Ys], (append(Xs, Ys, Zs)), Results),
print_results(Results).
print_results([]).
print_results([Result|Results]) :-
write(Result), nl,
print_results(Results).

8
A/cycle.P Normal file
View File

@ -0,0 +1,8 @@
edge(1,2).
edge(2,1).
edge(1,3).
path(X,Y) :- edge(X,Y).
path(X,Y) :- edge(X,Z), path(Z,Y), !.
cycle(X) :- path(X,X), !.

5
A/randomgen.py Normal file
View File

@ -0,0 +1,5 @@
import random
for i in range(10000):
j = random.randint(1,1000)
k = random.randint(1,1000)
print("edge(", j, ",", k, ").")

22
A/reach.P Normal file
View File

@ -0,0 +1,22 @@
source(3).
edge(0,1).
edge(1,2).
edge(1,5).
edge(2,5).
edge(3,5).
edge(3,5).
%input :- [reachin1000]. % one way of reading input facts
%:- include(reachin1000). % 2nd way of reading input facts
reach(X) :- source(X).
reach(Y) :- reach(X), edge(X,Y).
:- table reach/1.
printReach :- reach(X), write(X), write(' '), fail.
printReach.
%timeReach :- cputime(X), input, printReach, cputime(Y), T is Y-X, write(T).
%timeReach :- input, cputime(X), printReach, cputime(Y), T is Y-X, write(T).
timeReach :- cputime(X), printReach, cputime(Y), T is Y-X, write(T).

0
README.md Normal file
View File