Created
October 13, 2017 17:25
-
-
Save Rexagon/c6449d43935c2781e28c65c100973640 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOMAINS | |
list=i* | |
i=integer | |
PREDICATES | |
nondeterm main() | |
nondeterm input_list(list) | |
nondeterm make_positive(list, list) | |
nondeterm print_list(list) | |
CLAUSES | |
main():- | |
input_list(L), | |
make_positive(L, NewL), | |
print_list(NewL). | |
input_list([H|T]):- | |
write(">> "), | |
readint(H), | |
input_list(T). | |
input_list([]). | |
make_positive([],[]). | |
make_positive([H|T1], [H|T2]):- | |
H >= 0, | |
make_positive(T1, T2). | |
make_positive([H1|T1], [H2|T2]):- | |
H1 < 0, | |
H2 = -H1, | |
make_positive(T1, T2). | |
print_list([]). | |
print_list([H|T]):- | |
write(H, " "), | |
print_list(T). | |
GOAL | |
main(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment