- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前我正在摆弄有关 2D ST 数组和递归的 haskell 问题。
给定一个 2D 位置和一个方向数组,我写了一行返回数组内所有结果点的列表:
let cellsAround = [resPt | dir <- directions,
let resPt = (fst dir + fst point, snd dir + snd point),
fst resPt >= 0 && fst resPt <= fst maxIdx &&
snd resPt >= 0 && snd resPt <= snd maxIdx]
现在的目标是用数组的内容丰富结果列表项,我尝试了这个:
cellsAround <- sequence [readArray board resPt | dir <- directions,
let resPt = (fst dir + fst point, snd dir + snd point),
fst resPt >= 0 && fst resPt <= fst maxIdx &&
snd resPt >= 0 && snd resPt <= snd maxIdx]
这也很有效。但目标是获得 [(Point, Int)] 的组合,因为我必须过滤数组内容。
任何想法如何将其结合起来,比如说
(resPt, readArray board resPt)
?
最佳答案
最小的改变:
sequence [(,) resPt <$> readArray board resPt
| ...
关于arrays - Haskell:如何结合标量和单值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34064797/
我想对请求JSON进行解码,该请求JSON的值可以是单个字符串或数组(列表)。 我知道如何分别解析。但我正在寻找一种具有动态解码器来解析两者的方法。 JSON中的value字段就是我正在谈论的情况 单
这个问题在这里已经有了答案: Single result from database using mysqli (6 个答案) 关闭 3 年前。 我正在尝试编写一个函数,该函数将使用 mysqli
这个问题已经有答案了: Single result from database using mysqli (6 个回答) 已关闭 3 年前。 我正在尝试编写一个函数,该函数将使用 mysqli 检查数
在 MySQL 中这样做是不是很糟糕: SELECT ... WHERE foo IN ('bar') 而不是这个... SELECT ... WHERE foo = 'bar' ...鉴于此动态生成
这个问题在这里已经有了答案: Single result from database using mysqli (6 个答案) 关闭 2 年前。 我正在尝试编写一个函数,该函数将使用 mysqli
在我的 BehaviorSubject 中,address 元素有 2 个属性。在此如何单独更新单个属性? 这是我的尝试: myAddress:any = { "plot":32, "
例如,给定输入: { "values": ["APPLE", "PEAR", "BANANA"] } 对所需输出进行排序后: { "values": ["APPLE", "BANANA", "
在执行检查多个值的原始 SQL 时,我在使用 SQLAlchemy 时遇到了问题。 my_sess.execute( "SELECT * FROM table WHERE `key`=
我正在尝试在 mysql 存储过程中进行计数,但无法获得正确的语法 help1 delimiter// create procedure get_count_workmen_type(
是否可以在具有单个值的张量上运行 map_fn? 以下工作: import tensorflow as tf a = tf.constant(1.0, shape=[3]) tf.map_fn(lam
我正在寻找一种方法来查找总内存和正在使用的内存的单个熟值输出。 gwmi Win32_OperatingSystem | select TotalVisibleMemorySize, FreePhys
我是一名优秀的程序员,十分优秀!