手动评估'属于' a' [' a',' b',' c']`

时间:2014-05-06 18:51:26

标签: haskell evaluation ghci

我尝试手动评估belongs 'a' ['a', 'b', 'c']其中:

cuts :: [a] -> [([a],[a])]
cuts xs = zipWith splitAt [0..length xs] (repeat xs)

belongs x = any ((==x) . head . snd) . init . cuts

首先评估cuts ['a', 'b', 'c'] = [("","abc"),("a","bc"),("ab","c"),("abc","")]

然后我将init应用于cuts的输出:

init [("","abc"),("a","bc"),("ab","c"),("abc","")] = [("","abc"),("a","bc"),("ab","c")]

然后我对GHCi如何继续评估感到困惑。

PS:请注意belongsPrelude.elem具有相同的语义。

0 个答案:

没有答案