noart Navigation:noart Service: |
Programming in logicIs the meaning of Prolog. In "The Art of Prolog" by Sterling and Shapiro they say that Prolog is even a tool for thinking. I don't disagree. Old people are advised to solve crossword puzzles for keeping a good working memory and mind. Therefore I need prolog. It's not my intention to keep also young people from solving crossword puzzles. To get Prolog more popular there is a need for small real world application, examples doing somewhat useful. There are many implementations of the Prolog language, compiler and interpreter. Which one you like to use is a question of personal needs and preferences. Also available on WWW are interfaces to other languages like C, Java, SQL and so on.
The contributions I can offer at this time is a password generator,
a very simple text to html encoder
and a simple
|
+++ Commercial +++
+++ Commercial End +++ |
% © GPL'ed written by sax
% Errors? Not tested! Drop a mail.
bijektiv(N, M) :- surjektiv(N,M), injektiv(N,M).
surjektiv([], M) :-
list(M),
true,
!.
surjektiv([H|T], M) :-
memberchk(H, M),
surjektiv(T, M).
injektiv([], M) :-
list(M),
true,
!.
injektiv([H|T], M) :-
memberchk(H, M),
select(H, M, Mrest),
!,
injektiv(T, Mrest).
/*
GNU Prolog perdicates:
list(Term) succeeds if Term is currently instantiated to a list,
i.e. the atom [] (empty list) or a term with principal functor '.'/2
and with second argument (the tail) a list.
member(Element, List) succeeds if Element belongs to the List.
memberchk/2 is similar to member/2 but only succeeds once.
select(Element, List1, List2) removes one occurrence of Element in
List1 to provide List2. This predicate is re-executable on
backtracking.
*/