instantiation-error Questions

4

Solved

I am writing a little program which counts how many elements in a list are not numbers. Here is my code: not_number([],0). not_number([X|T],R):- not(number(X)), R1 is R+1, not_number(T,R1). ...
Torosian asked 22/5, 2014 at 19:54

4

Solved

This is my code:- fib(0,0). fib(1,1). fib(F,N) :- N>1, N1 is N-1, N2 is N-2, F is F1+F2, fib(F1,N1), fib(F2,N2), write(F," ,"). On consulting in GNU Prolog, I am getting: | ?- consult...
Amitie asked 1/4, 2014 at 19:58

5

I made a Prolog predicate posAt(List1,P,List2) that tests whether the element at position P of List1 and List2 are equal: posAt([X|Z], 1, [Y|W]) :- X = Y. posAt([Z|X], K, [W|Y]) :- K > 1, Kr...
Harbert asked 20/3, 2012 at 0:56

1

Solved

I'm learning Prolog, and as an exercise, I'm experimenting with a simple database that calculates the sum of all numbers up to the given number (i.e. 0=0, 1=1, 2=3, 3=6, 4=10, ...). Easy enough: c...
1

© 2022 - 2024 — McMap. All rights reserved.