tey*_*yvk 3 lookup filtering j apl dyalog
使用JI正在尝试执行类似于Bernard Legrand(2009)的Mastering Dyalog APL第128页上显示的以下示例的操作。我无法找到此代码到J的直接转换,这就是我想要的。
这是示例:
Run Code Online (Sandbox Code Playgroud)BHCodes ? 83 12 12 83 43 66 50 81 12 83 14 66 etc... BHAmounts ? 609 727 458 469 463 219 431 602 519 317 663 631...
13.3.2-第一个问题
我们将重点放在某些选定的国家(14、43、50、37和66)上,并计算其销售总额。首先让我们确定BHCode的哪些项目是相关的:
Run Code Online (Sandbox Code Playgroud)Selected ? 14 43 50 37 66 BHCodes ? Selected 0 0 0 0 1 1 1 0 0 0 1 1 0 1 0 ? Identifies sales in the selected countries only.
然后,我们可以将此过滤器应用于金额,并将其相加:
Run Code Online (Sandbox Code Playgroud)(BHCodes ? Selected) / BHAmounts 463 219 431 663 631 421 +/ (BHCodes ? Selected) / BHAmounts 2828
+/ (BHCodes e. Selected) # BHAmounts
Run Code Online (Sandbox Code Playgroud)
为了您的目的,APL ?
是J的e.
(成员(In)),APL /
是J的#
(副本)。
笔记:
APL ?
和J e.
并不完全等效,因为APL 在其右引数的元素中?
寻找左引数中的每个元素,而J 在每个主像元中寻找。它的左参数在其右参数的主要单元格中。e.
APL /
和J #
并不完全等效,因为APL /
沿尾轴运行,而J的#沿前轴运行。APL确实有?
,它沿引导轴运行。还有更多细微差别,但在这里不相关。