0

I want to after reaching the first contain, doing multiple functions like func1 then finc2 then fun3 is there any way to do that in haskell? I am not sure using >>?

myexe [] = []
myexe (x:xs) 
             | x < head xs             = myexe xs , func1, func2 , func3
             | otherwise               = x
4

3 回答 3

3

如果你想要几个函数,你总是可以写

result = f3 (f2 (f1 x))

或相同,使用功能应用程序

result = f3 $ f2 $ f1 x 

或相同,使用功能组合

result = f3 . f2 . f1 $ x

你可以在这里找到更多细节:LYAH

于 2013-10-11T19:00:52.903 回答
1

我不确定这是否是你想要的,但它可以是“让”:

| x < head xs             = let 
                              a = myexe xs
                              b = func1 a
                              c = func2 b
                  in func3 c
于 2013-10-11T21:35:54.320 回答
0

func1 2 和 3 的类型是什么?

你可以做 func1 。功能 2 。功能 3 。myexe xs 如果都是[a]->[a]

还要注意:

  1. x < head xs 可以head [],产生异常
  2. = x 如果 x 不是正确类型的列表,则错误。
于 2013-10-11T18:36:43.650 回答