This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.awt.*; | |
| import java.applet.*; | |
| import java.applet.*; | |
| import java.awt.*; | |
| import java.util.*; | |
| public class Clock extends Applet implements Runnable { | |
| Thread t,t1; | |
| public void start() { | |
| t = new Thread(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Cv> | |
| <Personal> | |
| <FirstName>John</FirstName> | |
| <SecondName>Doe</SecondName> | |
| <Sex>M</Sex> | |
| <Address>Earth</Address> | |
| <Mobile>1234567890</Mobile> | |
| </Personal> | |
| <Education> | |
| <Secondary>School Name</Secondary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| splitlist(L, [], L, 0). | |
| splitlist([H|T], [H|A], B, N) :- Nminus1 is N-1, splitlist(T, A, B, Nminus1). | |
| halfhalf(L, A, B) :- length(L, Len), Half is Len//2, splitlist(L, A, B, Half). | |
| merge(A, [], A). | |
| merge([], B, B). | |
| merge([Ha|Ta], [Hb|Tb], R) :- Ha =< Hb, merge(Ta, [Hb|Tb], M), R = [Ha|M]. | |
| merge([Ha|Ta], [Hb|Tb], R) :- Ha > Hb, merge(Tb, [Ha|Ta], M), R = [Hb|M]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| quicksort([], []). | |
| quicksort([HEAD | TAIL], SORTED) :- partition(HEAD, TAIL, LEFT, RIGHT), | |
| quicksort(LEFT, SORTEDL), | |
| quicksort(RIGHT, SORTEDR), | |
| append(SORTEDL, [HEAD | SORTEDR], SORTED). | |
| partition(PIVOT, [], [], []). | |
| partition(PIVOT, [HEAD | TAIL], [HEAD | LEFT], RIGHT) :- HEAD @=< PIVOT, | |
| partition(PIVOT, TAIL, LEFT, RIGHT). | |
| partition(PIVOT, [HEAD | TAIL], LEFT, [HEAD | RIGHT]) :- HEAD @> PIVOT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| insert_sort(List,Sorted):-i_sort(List,[],Sorted). | |
| i_sort([],Acc,Acc). | |
| i_sort([H|T],Acc,Sorted):-insert(H,Acc,NAcc),i_sort(T,NAcc,Sorted). | |
| insert(X,[Y|T],[Y|NT]):-X>Y,insert(X,T,NT). | |
| insert(X,[Y|T],[X,Y|T]):-X=<Y. | |
| insert(X,[],[X]). | |
| % insert_sort([0,2,4,1],X). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bubble_sort(List,Sorted):-b_sort(List,[],Sorted). | |
| b_sort([],Acc,Acc). | |
| b_sort([H|T],Acc,Sorted):-bubble(H,T,NT,Max),b_sort(NT,[Max|Acc],Sorted). | |
| bubble(X,[],[],X). | |
| bubble(X,[Y|T],[Y|NT],Max):-X>Y,bubble(X,T,NT,Max). | |
| bubble(X,[Y|T],[X|NT],Max):-X=<Y,bubble(Y,T,NT,Max). | |
| % bubble_sort([1,2,0,4,55,6],Sorted). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| move(1,X,Y,_) :- | |
| write('Move top disk from '), | |
| write(X), | |
| write(' to '), | |
| write(Y), | |
| nl. | |
| move(N,X,Y,Z) :- | |
| N>1, | |
| M is N-1, | |
| move(M,X,Z,Y), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fib(0, 0). | |
| fib(X, Y):- X > 0, fib(X, Y, _). | |
| fib(1, 1, 0). | |
| fib(X, Y1, Y2) :- X > 1, | |
| X1 is X - 1, | |
| fib(X1, Y2, Y3), | |
| Y1 is Y2 + Y3. | |
| % Nth Fibonacci number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gcd(0, X, X):- X > 0, !. | |
| gcd(X, Y, Z):- X >= Y, X1 is X-Y, gcd(X1,Y,Z). | |
| gcd(X, Y, Z):- X < Y, X1 is Y-X, gcd(X1,X,Z). | |
| % GCD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fact(0,1). | |
| fact(N,F):- N>0, N1 is N-1, | |
| fact(N1,F1), F is N*F1. | |
| % Factorial |