相关疑难解决方法(0)

总实时持久队列

Okasaki描述了可以使用该类型在Haskell中实现的持久实时队列

data Queue a = forall x . Queue
  { front :: [a]
  , rear :: [a]
  , schedule :: [x]
  }
Run Code Online (Sandbox Code Playgroud)

增量旋转保持不变量

length schedule = length front - length rear
Run Code Online (Sandbox Code Playgroud)

更多细节

如果您熟悉所涉及的队列,则可以跳过本节.

旋转功能看起来像

rotate :: [a] -> [a] -> [a] -> [a]
rotate [] (y : _) a = y : a
rotate (x : xs) (y : ys) a =
  x : rotate xs ys (y : a)
Run Code Online (Sandbox Code Playgroud)

它由智能构造函数调用

exec :: [a] -> [a] -> [x] -> Queue …
Run Code Online (Sandbox Code Playgroud)

queue haskell gadt dependent-type

15
推荐指数
1
解决办法
343
查看次数

标签 统计

dependent-type ×1

gadt ×1

haskell ×1

queue ×1