So far all of currently suggested solutions fail in the case of multiple replacements
q)t:100000 # flip (`pair`d1`d2`d3`d4`vol`adjustment)!(`pair1`pair2`pair3`pair4;("NC";"3/-0.09";"1/-0.09";"NC");("NC";"4/-0.09";"-1/-0.09";"NC");("NC";"2/-0.09";"1/0.09";"2/0.3");("NC";"4/-0.09";"0/-0.09";"NC");0 89.68 78.3 0;("0.1bp";"0.1bp";"0.1bp";"0.1bp"))
q)update adjustment:enlist"NO ADJ" from t where all(d1;d2;d3;d4)~\:\:"NC"
'length
[0] update adjustment:enlist"NO ADJ" from t where all(d1;d2;d3;d4)~\:\:"NC"
^
q)update adjustment:enlist"NO ADJ" from t where all (d1;d2;d3;d4) like\:"NC"
'length
[0] update adjustment:enlist"NO ADJ" from t where all (d1;d2;d3;d4) like\:"NC"
q)![`t;{(like;x;"NC")}each ((cols t) where (cols t) like "d*");0b;(enlist `adjustment)!enlist (enlist;"NO ADJ")]
'length
[0] ![`t;{(like;x;"NC")}each ((cols t) where (cols t) like "d*");0b;(enlist `adjustment)!enlist (enlist;"NO ADJ")]
^
This is because there is no easy way to determine the number of "NO ADJ" strings you need to substitute in.
'length
[0] update adjustment:enlist "adfjkl" from t where i in 1 2 3
^
q)update adjustment:3#enlist "adfjkl" from t where i in 1 2 3
pair d1 d2 d3 d4 vol adjustment
---------------------------------------------------------------
pair1 "NC" "NC" "NC" "NC" 0 "0.1bp"
pair2 "3/-0.09" "4/-0.09" "2/-0.09" "4/-0.09" 89.68 "adfjkl"
pair3 "1/-0.09" "-1/-0.09" "1/0.09" "0/-0.09" 78.3 "adfjkl"
pair4 "NC" "NC" "2/0.3" "NC" 0 "adfjkl"
pair1 "NC" "NC" "NC" "NC" 0 "0.1bp"
The best way to handle this type of vector replacment is through a vector conditional
q)update adjustment:?[&/[{"NC" ~/:x} each (d1;d2;d3;d4)];(count adjustment)#enlist "NO ADJ";adjustment] from t
pair d1 d2 d3 d4 vol adjustment
---------------------------------------------------------------
pair1 "NC" "NC" "NC" "NC" 0 "NO ADJ"
pair2 "3/-0.09" "4/-0.09" "2/-0.09" "4/-0.09" 89.68 "0.1bp"
pair3 "1/-0.09" "-1/-0.09" "1/0.09" "0/-0.09" 78.3 "0.1bp"
pair4 "NC" "NC" "2/0.3" "NC" 0 "0.1bp"
pair1 "NC" "NC" "NC" "NC" 0 "NO ADJ"
The performance of this will also generally be excellent.
Examining my conditional
?[&/[{"NC" ~/:x} each (d1;d2;d3;d4)];(count adjustment)#enlist "NO ADJ";adjustment]
In my where clause, {"NC" ~/:x} each (d1;d2;d3;d4) produces 4 vector boolean lists, I then collapse them with & (and) and the converge operation, to get where all conditions are true.
The other two components are my replacement vectors, they must be of equal length. This condition avoids the pitfalls of the other two attempts where you cannot know the number of replacements required.