Open Office 电子表格中的列表理解
列表理解是一种非常有用的代码机制,可以在多种语言中找到,例如 Haskell、Python 和 Ruby(仅举几个我想到的例子)。 我对这个结构很熟悉。
我发现自己正在处理一个 Open Office 电子表格,并且需要做一些相当常见的事情:我想要计算一系列单元格中位于上限和下限之间的所有值。 我立即认为列表理解可以解决问题,但我在 Open Office 中找不到任何类似的东西。 有一个名为“COUNTIF”的函数,它类似,但不完全是我需要的。
Open Office 中是否有可用于列表理解的构造?
List Comprehension is a very useful code mechanism that is found in several languages, such as Haskell, Python, and Ruby (just to name a few off the top of my head). I'm familiar with the construct.
I find myself working on an Open Office Spreadsheet and I need to do something fairly common: I want to count all of the values in a range of cells that fall between a high and low bounds. I instantly thought that list comprehension would do the trick, but I can't find anything analogous in Open Office. There is a function called "COUNTIF", and it something similar, but not quite what I need.
Is there a construct in Open Office that could be used for list comprehension?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设:
那么您想要的可以通过以下方式实现:(
您可能需要将逗号更改为分号,具体取决于您对小数点的语言偏好)
引用自安装的 OpenOffice 文档:
Assuming:
then what you want can be achieved by:
(you might need to change commas into semicolons, depending on your language preference for decimal point)
Quoting from the installed OpenOffice documentation:
CountIf 可以计算等于所选值的值。 不幸的是,似乎没有合适的候选函数来实现这种功能。 或者,您可以使用带有 If 的附加列来显示 1 或 0(如果值符合或不相应地显示 1 或 0):
那么剩下的就是对这个附加列求和。
CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. Alternatively you can use additional column with If to display 1 or 0 if the value fits in range or not accordingly:
Then only thing left is to sum up this additional column.