Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to find maximum number from inputted numbers

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 10540

Program to find maximum number from inputted numbers.

Code for ProLog Program to find maximum number from inputted numbers in Artificial Intelligence

%trace
domains
    no_list = integer*

database
    numbers(integer)
    temp(integer)

predicates
%    nos(no_list)
    find_maximum()
%    insert_into_db(integer,no_list)
%    display_db()
    go
    initialize

goal
    go.

clauses

/*    go :-%        nos([5,6,3,8,9]),        insert_into_db(5,[5,6,7,8,9]).    insert_into_db(CNT,[H|T]) :-        assert(numbers(H)),        CNT1 = CNT - 1,        CNT1 > 0,        insert_into_db(CNT1,T).    insert_into_db(0,[H|T]) :-        display_db().    display_db() :-        numbers(N),        write(N), nl,        fail.*/

    go :-
        initialize,
        find_maximum().

    initialize :-
        
        assert(numbers(5)),
        assert(numbers(8)),
        assert(numbers(9)),
        assert(numbers(2)),
        assert(numbers(4)),

        assert(temp(0)).

    find_maximum() :-
        numbers(NO),
        temp(NO1),
        NO > NO1,
        retract(temp(NO1)),
        assert(temp(NO)),
        write(NO1), nl,
        fail.
    
  
Share: 



Milind Mishra
Milind Mishra author of ProLog Program to find maximum number from inputted numbers is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!