fix by UN to do type checking on sort.
This commit is contained in:
parent
b1ee4dfb0d
commit
756bba9bc5
21
pl/sort.yap
21
pl/sort.yap
@ -54,6 +54,27 @@ length(L, M) :-
|
|||||||
M is N + 1, NL = [_|L], '$$_length2'(L, O, M) ).
|
M is N + 1, NL = [_|L], '$$_length2'(L, O, M) ).
|
||||||
|
|
||||||
sort(L,O) :-
|
sort(L,O) :-
|
||||||
|
'$skip_list'(L,NL,RL),
|
||||||
|
( RL == [] -> true ;
|
||||||
|
var(RL) -> '$do_error'(instantiation_error,sort(L,O)) ;
|
||||||
|
'$do_error'(type_error(list,L),sort(L,O))
|
||||||
|
),
|
||||||
|
(
|
||||||
|
nonvar(O)
|
||||||
|
->
|
||||||
|
(
|
||||||
|
O == []
|
||||||
|
->
|
||||||
|
L == []
|
||||||
|
;
|
||||||
|
'$skip_list'(O,NO,RO),
|
||||||
|
( RO == [] -> NO =< NL ;
|
||||||
|
var(RO) -> NO =< NL ;
|
||||||
|
'$do_error'(type_error(list,O),sort(L,O))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
; true
|
||||||
|
),
|
||||||
'$sort'(L,O).
|
'$sort'(L,O).
|
||||||
|
|
||||||
msort(L,O) :-
|
msort(L,O) :-
|
||||||
|
Reference in New Issue
Block a user