我试图在一个函数中写3-4 where语句但我得到错误并且无法做到,我试图做类似的事情:
foo x=
| x == foo1 = 5
| x == foo2 =3
| x == foo3 =1
| otherwise =2
where foo1= samplefunct1 x
foo2= samplefunct2 x
foo3= samplefunct3 x
Run Code Online (Sandbox Code Playgroud)
我知道代码有点无用,但我只是写了这个来举例说明我的意思.
有没有人可以帮助我?提前致谢.
syntax haskell where-clause guard-clause function-definition