【发布时间】:2017-05-19 20:58:30
【问题描述】:
涉足 Idris,我试图将 this Haskell function 移植到 Idris。我想我成功了,用这段代码......
windowl : Nat -> List a -> List (List a)
windowl size = loop
where
loop xs = case List.splitAt size xs of
(ys, []) => if length ys == size then [ys] else []
(ys, _) => ys :: loop (drop 1 xs)
但是,当我在交互式 idris 中调用它时,似乎只评估了对函数的第一次调用,递归的下一步不是。这就是我在控制台上得到的。
*hello> windowl 2 [1,2,3,4,5]
[1, 2] :: Main.windowl, loop Integer 2 [2, 3, 4, 5] : List (List Integer)
有人可以告诉我正在发生的事情以及如何完全评估函数吗?
【问题讨论】: