- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Simon Marlow 在他的书《Haskell 中的并行和并发编程》中写道:
The insert operation hadthis line:
putMVar m (Map.insert name number book)
This places in the MVar the unevaluated expression
Map.insert name number book
.If we were to do many insert operations consecutively, the MVar would build up a large chain of unevaluated expressions.To get brief locking and no space leaks, we need to usea trick:let book' = Map.insert name number book
putMVar m book'
seq book' (return ())With this sequence, we’re storing an unevaluated expression in the MVar, but it is evaluated immediately after the putMVar.
我不明白。 seq a b
运算以弱头范式计算 a
。所以就会出现未评估的表达。正如我所看到的,只有 Map 构造函数将被评估,并且所有内容都将被不评估。
最佳答案
As I can see only the
Map
constructor will be evaluated and all of it contents will be unevaluated.
在内部,Map
类型是使用严格树实现的。要么评估整个树干,要么不评估。这是库代码的片段:
data Map k a = Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a)
| Tip
严格注释 (!
) 防止未计算的值存储为子树。因此,如果我们将 Map k a
值评估为弱头范式,我们实际上完全评估了树干。
关于haskell - Simon Marlow 书中的严格评估示例 "Parallel and Concurrent Programming in Haskell",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67519876/
这是我在这个网站上的第一篇文章,所以如果我违反了规则或我不知道的东西,我非常抱歉。也就是说,我的老师指派我制作西蒙说项目,但我在类里面遇到了困难,所以我正在寻找其他帮助途径。规则如下: 完成这项任务的
我正在编写游戏“西蒙”的代码,但我在弄清楚如何使用可运行对象和处理程序时遇到了一些麻烦。这是针对游戏的一部分,在玩家必须按下按钮之前,颜色会按顺序模式亮起。 这是我目前的代码: Handler han
我正在尝试用 Javascript 为学校制作一个 simon 游戏。我目前已设置代码以自行创建颜色数组序列,并且还成功地将用户答案保存到它自己的数组中,该数组会在新序列时被清除。我现在想看看所说的颜
我正在为 FreecodeCamp 编写一个“Simon Says”元素,该元素跟踪计算机的随机颜色选择以及用户单击响应以遵循亮起颜色的模式。 但是,我遇到了一个问题。 。 。当计算机随机运行选择时,
我正在制作西蒙游戏,我已经添加了逻辑,但我不知道如何暂停执行,直到玩家按下图 block 。我创建了一个名为 user() 的函数,用于记录用户输入并将其推送到 userSeq 数组。然后我创建了一个
我正在开发 Simon Says 游戏,但我无法将标题和按钮从底部放到控件部分的中间。我尝试了不同的 css 样式,但 div 似乎没有移动。 特别是 margin-top 将元素移到更靠近中间的位置
我正在学习 Cocoa/Objective-C/iPhone SDK,作为一个应用我所学知识的简单项目,我想创建一个旧版 Simon 游戏的简单版本。四个彩色按钮,向您显示一个序列(红色、绿色、蓝色、
我试图找出原因 1) 我的 Simon 游戏在说“输入数字”后挂起 - 它看起来甚至没有通过验证。我正在尝试获取用户输入,并检查当时按下的数字是否正确。 2)此外,它曾经生成一个随机数,但当用户按下它
您可以在“圆周率的近似值”维基百科文章中查看圆周率公式。我被这个公式所吸引,因为它紧凑并且 promise 高效计算,而且它专门用于以 10 为基数。公式是 pi = -3 + SUM(n=0,oo
Simon Marlow 在他的书《Haskell 中的并行和并发编程》中写道: The insert operation hadthis line: putMVar m (Map.insert na
Simon Marlow 在他的书《Haskell 中的并行和并发编程》中写道: The insert operation hadthis line: putMVar m (Map.insert na
我在之前的帖子中进行了搜索,但似乎找不到解决方案,我的代码工作得很好,直到我做错了什么,现在我得到“错误:无法找到或加载主类 games.Game”我想我可能删除了 Eclipse 配置中的某些内容,
由于某种原因Graphics2D不会生成我尝试设置的背景。我认为问题与渲染器将信息发送回主类 Simon 有关。我似乎找不到解决方案,并且一直在网上寻找几个小时。如果有人很了解 2D 图形或者看到
我在我的 Android 应用程序中使用 Simon 的 ICS 日期选择器库 ( https://github.com/SimonVT )。我有一个日期按钮,如果我点击那个按钮,它会在对话框中显示
我是一名优秀的程序员,十分优秀!