new files

This commit is contained in:
Ingy döt Net 2013-04-10 12:38:42 -07:00
parent 3af7344581
commit 86c034bb8b
1364 changed files with 21352 additions and 0 deletions

View file

@ -0,0 +1,23 @@
search_a_list(N1, N2) :-
L = ["Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Boz", "Zag"],
write('List is :'), maplist(my_write, L), nl, nl,
( nth1(Ind1, L, N1) ->
format('~s is in position ~w~n', [N1, Ind1])
; format('~s is not present~n', [N1])),
( nth1(Ind2, L, N2) ->
format('~s is in position ~w~n', [N2, Ind2])
; format('~s is not present~n', [N2])),
( reverse_nth1(Ind3, L, N1) ->
format('~s last position is ~w~n', [N1, Ind3])
; format('~s is not present~n', [N1])).
reverse_nth1(Ind, L, N) :-
reverse(L, RL),
length(L, Len),
nth1(Ind1, RL, N),
Ind is Len - Ind1 + 1.
my_write(Name) :-
writef(' %s', [Name]).