This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
polynomialmani.pl/README.md

45 lines
1.0 KiB
Markdown
Raw Normal View History

# How to run
Run
$ swipl
Inside the REPl, load the file
?- ["polimani.pl"].
> Note: Don't forget the dot at the end of the line.
The user available funtions are:
1) poly2list/2
2) simpoly_list/2
3) simpoly/2
4) scalepoly/3
5) addpoly/3
> Note: In the docs, `foo/N` means the funciton `foo` has `N` parameters.
These names are the ones requested in the assignment.
# Tests
```
:- ["polimani.pl"].
%@ true.
?- poly2list(2*x^2+3*x+5*x^17-7*x^21+3*x^3+25*x^5-4.3, S).
%@ S = [-4.3, 25*x^5, 3*x^3, -7*x^21, 5*x^17, 3*x, 2*x^2].
?- simpoly_list([x*x*x, x^3, 5*x^3, 4.2*z, 2, 42.6, 42*y, 5*z, z^7, z*y^1337, 0], L).
%@ L = [44.6, 7*x^3, 9.2*z, 42*y, y^1337*z, z^7].
?- simpoly(1+x+1+x+1+x+1+x^3+5*x^3+42*x^1337+0, S).
%@ S = 42*x^1337+6*x^3+3*x+4.
?- scalepoly(2*x^2+3*x+5*x^17-7*x^21+3*x^3-23*x^4+25*x^5-4.3, 42, S).
%@ S = 1050*x^5+210*x^17+126*x^3+126*x+84*x^2-294*x^21-966*x^4-180.6.
?- addpoly(2*x^2+3*x+5*x^17-x^4+25*x^5-4.3, 42*x^1337+0-5, S).
%@ S = 42*x^1337+25*x^5+5*x^17+3*x+2*x^2-1*x^4-9.3.
```