Recent public codes are listed below. You can filter them by the following programming languages:
- view
- All
- Ada
- Assembler
- Assembler
- AWK (gawk)
- AWK (mawk)
- Bash
- bc
- Brainf**k
- C
- C#
- C++
- C++0x
- C99 strict
- CLIPS
- Clojure
- COBOL
- COBOL 85
- Common Lisp (clisp)
- D (dmd)
- Erlang
- F#
- Factor
- Falcon
- Forth
- Fortran
- Go
- Groovy
- Haskell
- Icon
- Intercal
- Java
- JavaScript (rhino)
- JavaScript (spidermonkey)
- Lua
- Nemerle
- Nice
- Nimrod
- Objective-C
- Ocaml
- Oz
- Pascal (fpc)
- Pascal (gpc)
- Perl
- Perl 6
- PHP
- Pike
- Prolog (gnu)
- Prolog (swi)
- Python
- Python 3
- R
- Ruby
- Scala
- Scheme (guile)
- Smalltalk
- SQL
- Tcl
- Text
- Unlambda
- VB.NET
- Whitespace
-
1 2 3 4 5
parent( mary, john). parent( ann, mary). female( mary). mother( x, y) :- parent( x, y), female( x). grandparent( x, y) :- parent( x, z), parent( z, y).
-
1
parent(Jo, Jill).
-
1 2 3 4 5
parent( mary, john). parent( ann, mary). female( mary). mother( x, y) :- parent( x, y), female( x). grandparent( x, y) :- parent( x, z), parent( z, y).
-
1 2 3 4 5
parent( mary, john). parent( ann, mary). female( mary). mother( x, y) :- parent( x, y), female( x). grandparent( x, y) :- parent( x, z), parent( z, y).
-
1 2 3 4 5
parent( mary, john). parent( ann, mary). female( mary). mother( X, Y) :- parent( X, Y), female( X). grandparent( X, Y) :- parent( X, Z), parent( Z, Y).
-
1 2 3 4 5
parent( mary, john). parent( ann, mary). female( mary). mother( X, Y) :- parent( X, Y), female( X). grandparent( X, Y) :- parent( X, Z), parent( Z, Y).
-
1 2 3 4 5 6 7 8
i( _,[],1 ). i( [],_,1 ). i( [A|R],[B|S],W ) :- i( R,S,P ), W is P + A*B. :- i( [1,2,3],[1,2,3],W ), writeln(W). :- i( [1,2,1,2],[1],W ), writeln(W). :- i( [1,2,3,4],[],W ), writeln(W). :- i( [5,3,3],[4,2,2,3],W ), writeln(W).
-
1 2 3 4 5 6 7 8 9
i( [],_,0 ). i( _,[],0 ). i( [A|R],[A|S],W ) :- i( R,S,P ), W is P + 1. i( [_|R],[_|S],W ) :- i( R,S,P ), W is P. :-i( [1,2,3,4],[1,3,2,4],I ),writeln(I). :-i( [1,2,3,4],[1,2,3,4],I ),writeln(I). :-i( [4,3,2,1],[1,2,3,4],I ),writeln(I).
...
-
1 2 3 4 5 6 7 8 9
i( [],_,0 ). i( _,[],0 ). i( [A|R],[A|S],W ) :- i( R,S,P ), W is P + 1. i( [_|R],[_|S],W ) :- i( R,S,P ), W is P. :-i( [1,2,3,4],[1,3,2,4],I ). :-i( [1,2,3,4],[1,2,3,4],I ). :-i( [4,3,2,1],[1,2,3,4],I ).
...
-
1 2 3 4 5 6 7 8 9
i( [],_,0 ). i( _,[],0 ). i( [A|R],[A|S],W ) :- i( R,S,P ), W is P + 1. i( [_|R],[_|S],W ) :- i( R,S,P ), W is P. i( [1,2,3,4],[1,3,2,4],I ). i( [1,2,3,4],[1,2,3,4],I ). i( [4,3,2,1],[1,2,3,4],I ).
...
-
1 2 3 4 5 6 7
scoop(vanilla). scoop(strawberry). scoop(chocolate). cone(Top,Middle,Bottom):-scoop(Top), scoop(Middle), scoop(Bottom). go:- setof(X+Y+Z, cone(X,Y,Z), List), length(List, N), write(N). go2:- cone(X,Y,Z), write(X+Y+Z), nl, fail. go3:- setof(X+Y+Z, (cone(X,Y,Z), X\=Y, Y\=Z, X\=Z), List), length(List, N), write(N),nl.
-
1 2 3 4 5 6 7 8 9
bsearch(X,Lo,Hi,Y):-Hi=:=Lo+1, X is Lo. bsearch(X,Lo,Hi,Y):-Hi < Lo+1, fail. bsearch(X,Lo,Hi,Y):-Hi>= Lo+1, Mid is (Lo+Hi)//2, f(Mid, Val), ( Val=<Y, bsearch(X,Mid,Hi,Y) ; Val>Y, bsearch(X,Lo,Mid,Y) ). go:-bsearch(X,1,100,49), nl,nl,print(X),nl.
-
1 2 3 4 5 6 7 8 9
mother_child(trude, sally). father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). parent_child(X, Y) :- father_child(X, Y).
...
-
1 2 3 4 5 6 7 8 9
mother_child(trude, sally). father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). parent_child(X, Y) :- father_child(X, Y).
...
-
1 2 3 4 5
?- write('Hello world!'), nl. Hello world! true. ?-
-
1
f = 3
-
1 2 3 4
program :- get_char(X),get_char(Y),check(X,Y). check('4','2'):-!. check(X,Y):-write(X),get_char(Z),check(Y,Z). :- program.
-
1 2 3 4
program :- get_char(X),get_char(Y),check(X,Y). check('4','2'):- write('Finished'),!. check(X,Y):-write('|'), write(X), write('|'), write(Y), write('|'), nl, get_char(Z),check(Y,Z). :- program.
-
1 2 3 4 5 6 7 8 9
edge(1,2). edge(1,3). edge(2,4). edge(3,4). edge(3,5). edge(3,6). edge(5,7). edge(6,7). isedge(X,Y):-edge(X,Y).
...
-
1 2 3 4 5 6 7 8 9
man('Haakon VII'). man('Olav V'). man('Harald V'). man('Haakon'). woman('Martha'). woman('Mette-Marit'). woman('Maud'). woman('Sonja'). parent('Haakon VII','Olav V').
...
-
1 2 3 4 5 6 7 8 9
man('Haakon VII'). man('Olav V'). man('Harald V'). man('Haakon'). woman('Martha'). woman('Mette-Marit'). woman('Maud'). woman('Sonja'). parent('Haakon VII','Olav V').
...
-
1 2 3 4 5 6 7 8 9
man('Haakon VII'). man('Olav V'). man('Harald V'). man('Haakon'). woman('Martha'). woman('Mette-Marit'). woman('Maud'). woman('Sonja'). parent('Haakon VII','Olav V').
...
-
1 2 3 4 5 6 7 8 9
man('Haakon VII'). man('Olav V'). man('Harald V'). man('Haakon'). woman('Martha'). woman('Mette-Marit'). woman('Maud'). woman('Sonja'). parent('Haakon VII','Olav V').
...
-
1 2 3 4 5 6 7 8 9
man(’Haakon VII’). man(’Olav V’). man(’Harald V’). man(’Haakon’). woman(’Martha’). woman(’Mette-Marit’). woman(’Maud’). woman(’Sonja’). parent(’Haakon VII’,’Olav V’).
...
-
1 2 3 4 5 6 7 8 9
witch(X) <= burns(X) and female(X). burns(X) <= wooden(X). wooden(X) <= floats(X). floats(X) <= sameweight(duck, X). female(girl). {by observation} sameweight(duck,girl). {by experiment } ? witch(girl).
...
-
1 2 3 4
program :- get_char(X),get_char(Y),check(X,Y). check('4','2'):-!. check(X,Y):-write(X),get_char(Z),check(Y,Z). :- program.
-
1 2
countdown(0) :- write(0), !. countdown(N) :- write(N), nl, M is N - 1, countdown(M).
-
1 2 3
cube :- read(X), calc(X). calc(stop) :- write(done). calc(X) :- C is X * X * X, write(C), cube.
-
1 2 3
cube :- read(X), calc(X). calc(stop) :- write(done). calc(X) :- C is X * X * X, write(C), cube.
-
1 2 3
cube :- read(X), calc(X). calc(stop) :- write(done). calc(X) :- C is X * X * X, write(C), cube.


