at_end_of_line
max_list,min_list git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1237 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
2ce853ec5f
commit
ee8e119602
16
docs/yap.tex
16
docs/yap.tex
@ -7217,9 +7217,9 @@ Holds when @code{append(_,Suffix,List)} holds.
|
|||||||
|
|
||||||
@item sum_list(?@var{Numbers}, ?@var{Total})
|
@item sum_list(?@var{Numbers}, ?@var{Total})
|
||||||
@findex sum_list/2
|
@findex sum_list/2
|
||||||
@snindex sum_list/2
|
@syindex sum_list/2
|
||||||
@cnindex sum_list/2
|
@cnindex sum_list/2
|
||||||
True when @var{Numbers} is a list of integers, and @var{Total} is their sum.
|
True when @var{Numbers} is a list of numbers, and @var{Total} is their sum.
|
||||||
|
|
||||||
@item sumlist(?@var{Numbers}, ?@var{Total})
|
@item sumlist(?@var{Numbers}, ?@var{Total})
|
||||||
@findex sumlist/2
|
@findex sumlist/2
|
||||||
@ -7229,6 +7229,18 @@ True when @var{Numbers} is a list of integers, and @var{Total} is their
|
|||||||
sum. The same as @code{sum_list/2}, please do use @code{sum_list/2}
|
sum. The same as @code{sum_list/2}, please do use @code{sum_list/2}
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
@item max_list(?@var{Numbers}, ?@var{Max})
|
||||||
|
@findex max_list/2
|
||||||
|
@syindex max_list/2
|
||||||
|
@cnindex max_list/2
|
||||||
|
True when @var{Numbers} is a list of numbers, and @var{Max} is the maximum.
|
||||||
|
|
||||||
|
@item min_list(?@var{Numbers}, ?@var{Min})
|
||||||
|
@findex min_list/2
|
||||||
|
@syindex min_list/2
|
||||||
|
@cnindex min_list/2
|
||||||
|
True when @var{Numbers} is a list of numbers, and @var{Min} is the minimum.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node Ordered Sets, Pseudo Random, Lists, Library
|
@node Ordered Sets, Pseudo Random, Lists, Library
|
||||||
|
@ -26,8 +26,10 @@
|
|||||||
suffix/2,
|
suffix/2,
|
||||||
sumlist/2,
|
sumlist/2,
|
||||||
list_concat/2,
|
list_concat/2,
|
||||||
flatten/2
|
flatten/2,
|
||||||
]).
|
max_list/2,
|
||||||
|
min_list/2
|
||||||
|
]).
|
||||||
|
|
||||||
|
|
||||||
% append(Prefix, Suffix, Combined)
|
% append(Prefix, Suffix, Combined)
|
||||||
@ -331,3 +333,29 @@ flatten_list([]) --> !.
|
|||||||
flatten_list([H|T]) --> !, flatten_list(H),flatten_list(T).
|
flatten_list([H|T]) --> !, flatten_list(H),flatten_list(T).
|
||||||
flatten_list(H) --> [H].
|
flatten_list(H) --> [H].
|
||||||
|
|
||||||
|
max_list([H|L],Max) :-
|
||||||
|
max_list(L,H,Max).
|
||||||
|
|
||||||
|
max_list([],Max,Max).
|
||||||
|
max_list([H|L],Max0,Max) :-
|
||||||
|
(
|
||||||
|
H > Max0
|
||||||
|
->
|
||||||
|
max_list(L,H,Max)
|
||||||
|
;
|
||||||
|
max_list(L,Max0,Max)
|
||||||
|
).
|
||||||
|
|
||||||
|
min_list([H|L],Max) :-
|
||||||
|
max_list(L,H,Max).
|
||||||
|
|
||||||
|
min_list([],Max,Max).
|
||||||
|
min_list([H|L],Max0,Max) :-
|
||||||
|
(
|
||||||
|
H < Max0
|
||||||
|
->
|
||||||
|
max_list(L, H, Max)
|
||||||
|
;
|
||||||
|
max_list(L, Max0, Max)
|
||||||
|
).
|
||||||
|
|
||||||
|
10
pl/yio.yap
10
pl/yio.yap
@ -873,6 +873,16 @@ at_end_of_stream(S) :-
|
|||||||
'$peek'(S,N), N = -1.
|
'$peek'(S,N), N = -1.
|
||||||
|
|
||||||
|
|
||||||
|
at_end_of_line :-
|
||||||
|
current_input(S),
|
||||||
|
at_end_of_line(S).
|
||||||
|
|
||||||
|
at_end_of_line(S) :-
|
||||||
|
'$past_eof'(S), !.
|
||||||
|
at_end_of_line(S) :-
|
||||||
|
'$peek'(S,N), ( N = 10 -> true ; N = -1).
|
||||||
|
|
||||||
|
|
||||||
consult_depth(LV) :- '$show_consult_level'(LV).
|
consult_depth(LV) :- '$show_consult_level'(LV).
|
||||||
|
|
||||||
absolute_file_name(V,Out) :- var(V), !,
|
absolute_file_name(V,Out) :- var(V), !,
|
||||||
|
Reference in New Issue
Block a user