当我使用-Wall选项编译时,我收到以下错误.
ghc -o -Wall polycake polycake.hs
Run Code Online (Sandbox Code Playgroud)
当我不使用该选项时,我的代码编译正常并按预期运行.这是什么意思?
<no location info>: error:
module ‘main:Polycake’ is defined in multiple files: polycake.hs
polycake.hs
Run Code Online (Sandbox Code Playgroud) 我试图推理如何将命令式样式程序转换为像Haskell这样的功能性程序.
功能是:
void calcPerim(point polycake[], int v, int y, double *perim1, double *perim2){
int next = 0;
int index = 0;
point points[2];
*perim1 = 0.0;
*perim2 = 0.0;
for(int i = 0; i < v; i++)
{
next = (i + 1) % v;
if(polycake[i].y < y && polycake[next].y < y)
(*perim1) += distance(polycake[i], polycake[next]);
else if(polycake[i].y > y && polycake[next].y > y)
(*perim2) += distance(polycake[i], polycake[next]);
else
{
points[index] = intersectPoint(polycake[i], polycake[next], y);
if(polycake[i].y < y)
{
(*perim1) …Run Code Online (Sandbox Code Playgroud)