考虑:
[xs=. 'hi';'hello';'foo'
┌──┬─────┬───┐
│hi│hello│foo│
└──┴─────┴───┘
我寻找默认连词adjust
,以便:
(,&' world' adjust 1) xs
产生
┌──┬───────────┬───┐
│hi│hello world│foo│
└──┴───────────┴───┘
如果他们更适合这个问题,我也会接受其他方法。
答案 0 :(得分:2)
我确实采用了一种不同的方法,用动词而不是连词来创建结果。我能够保持参数相对可调,以便在不改变结构的情况下易于操作。我这样做是通过创建一个二元动词,其中要选择的方框是左参数,方框列表是左参数,要添加的后缀嵌入动词中。
suffix=.''&;
1 (] ,each (suffix ' world') {~ (= i.@#)) xs
+--+-----------+---+
|hi|hello world|foo|
+--+-----------+---+
2 (] ,each (suffix 'die') {~ (= i.@#)) xs
+--+-----+------+
|hi|hello|foodie|
+--+-----+------+
0 (] ,each (suffix ' there') {~ (= i.@#)) xs
+--------+-----+---+
|hi there|hello|foo|
+--------+-----+---+
完全原始的默会版本可能如下所示。
0 (] ,each ('';' there') {~ (= i.@#)) xs
+--------+-----+---+
|hi there|hello|foo|
+--------+-----+---+