Q:

How to use the predicate "assert" in a predicate

I have a problem I want a code Prolog for that I will generate new predicate with the predicate "assert" but I want to use the result of my predicate .
i have a predicate that counts the number of element of a list here is it 
and I have to make a new predicate that will add me a new predicate using the predicate "assert" in my knowledge base calling to the predicate "creat_nbStation" who will use the 2 "assert" and "compte" for exemple i have creat_nbStation(L) and L is a Liste it will add me in my knowledge base a new predicate it's nb_Station(L,25) using assert predicate .
thank you for the help.
this is my predicate for counting the number of elements of a list and it worka perfectly 
compte([],0).
compte([_|R],N) :- compte(R,N1), N is N1+1, N>0.

A:

It is quite difficult to figure out what exactly you are looking for, but I must say it does look very much like homework assignment. Is this what you are looking for?
create_nbStation(L) :- compte(L, N), assert(nbStation(L, N)).

