Prolog code

Write a tail-recursive Prolog procedure count_vars(L,N) that counts the number of instantiated variables in the list Land returns the result in N

Sounds like your homework.

For instantiated check, use ground/1