I am working on writing an insert function that takes two arguments, a number and a sorted list and it should produce that same list with the number included in its proper position. Here's what I got so far:
insert1(X,[]) :-
[X].
insert1(X, [H|T]) :-
X > H,
insert1(X,T).
insert1(X,[H|_T]) :-
X < H,
T is [X|T].
I am getting the following error:
ERROR: '.'/2: Arguments are not sufficiently instantiated ("x" must hold one character)
Exception: (6) insert1(2, [1, 4, 5]) ? creep
I would appreciate your help folks.