Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to find length of names

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

Program to find length of names.

Code for ProLog Program to find length of names in Artificial Intelligence

%trace
domains
    strlist = symbol*

predicates
    find_grt(strlist,integer)
    find_less(strlist,integer)
%    find_len_list(strlist)
%    find_len(integer)
    names(strlist)
    display1(string,integer,integer)
    display2(string,integer,integer)
    choice(integer)
    repeate

clauses
    repeate.
    repeate :- repeate.

    names([harshad,hemal,shashank,abc,nr,khilan,pk]).

/*    find_len(CNT) :-        CNT1 = CNT / 2.*/

    find_grt([H|T],CNT) :-
        TMPLIST = [H|T],
        str_len(H,LEN),
        display1(H,LEN,CNT),
        find_grt(T,CNT).

    find_less([H|T],CNT) :-
        TMPLIST = [H|T],
        str_len(H,LEN),
        display2(H,LEN,CNT),
        find_less(T,CNT).


    display1(X,L,CNT) :-
        L > CNT, nl,
        write(X),
        fail.

    display1(X,L,CNT).

    display2(X,L,CNT) :-
        L < CNT, nl,
        write(X),
        fail.

    display2(X,L,CNT).

    choice(1) :-
        CNT1 = 7 / 2,
        names(S_LIST),
        find_less(S_LIST,CNT1).

    choice(2) :-
        CNT1 = 7 / 2,
        names(S_LIST),
        find_grt(S_LIST,CNT1).

    choice(0) :- !.

    goal 
        repeate,
        
        write("\n\n1. Less then"),
        write("\n2. Greater then"),
        write("\n0. Exit"),
        write("\n\nEnter your choice : "),
        readint(CH),
        choice(CH).
  
Share: 


Didn't find what you were looking for? Find more on ProLog Program to find length of names Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of ProLog Program to find length of names 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!