组织电子表格的表格公式

use*_*450 6 emacs org-mode org-table

我有一张桌子如下:

| Xn | S | Pn |
| 0  | 0 | 0  |
| 1  | 0 | 1  |
| 0  | 1 | 0  |
| 1  | 1 | 0  |
Run Code Online (Sandbox Code Playgroud)

我想通过栏目来搜索XnS和返回的值Pn为此Xn=1 and S=0.

任何人都可以建议我如何做到这一点?

hua*_*uan 5

#+tblname: example-table
| Xn | S | Pn |
|  0 | 0 |  0 |
|  1 | 0 |  1 |
|  0 | 1 |  0 |
|  1 | 1 |  0 |

#+source: compute-table
#+begin_src emacs-lisp :var table=example-table
(require 'cl)
(loop for (xn s pn) in (rest table)
      when (and (= xn 1) (= s 0)) collect pn)
#+end_src

#+results: compute-table
| 1 |
Run Code Online (Sandbox Code Playgroud)


Tom*_*ner 2

使用 org-babel:命名表并将其用作函数的输入,该函数以您选择的语言(在 org 支持的多种语言中)进行搜索。

在伪代码中:

#+tblname: my_table
|Xn|S|Pn|
| 0|0|9 |
[...]

#+name filter_table
#+begin_src lang :var tbl=my_table :results output
  filter tbl # tbl (my_table by default) is passed in as array of arrays (or list of lists)
  print matching Pn
#+end_src
Run Code Online (Sandbox Code Playgroud)