Source Code :
/* Delete a number in the list */
delte(1,[_|T],T).
delte(P,[X|Y],[X|R]):-
P1 is P-1,
delte(P1,Y,R).
/* Delete before and after */
del(P,L,R):-
length(L,L1),
(
P=:=1 ->
P3 is P+1,
delte(P3,L,R)
;
P=:=L1 ->
P3 is P-1,
delte(P3,L,R)
;
P1 is P-1,
delte(P1,L,R1),
/* Delete before */
delte(P,R1,R)
/* Delete after */
).
Output :
No comments:
Post a Comment