SasseMan 49 Junior Poster

Hi, Im kind of new to prolog and would like som help.

I want to write a rule that only takes integers as input like the following example.

rule( X, [] ).
rule( X "is integer", [Heat|Tail] ) :- rule(X, Tail).
rule( X "is anything else", [Heat|Tail] ) :- rule(X, Tail)

Is this functionality avaliable? I want the rule only to be called if X is and Integer and the other rule otherwise. I don't not want to test if X is an integer like this...

rule(X, [Head|Tail]) :- integer(X), rule(X,Tail).

Anyone who can help?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.