I have the following function to identify null symbols, where ns should represent the null symbol.
#include"k.h"
K test (K x) {
K ns = ks("");
if (abs(x->t) != KS) {
R krr("type");
}
if (x->t > 0) {
K res = ktn(KB,x->n);
for (int i=0;i<x->n;++i){
if (kK(x)[i] == ns) {
kG(res)[i] = 1;
}
else {
kG(res)[i] = 0;
}
}
R res;
}
else {
if (x == ns) {
R kb(1);
}
else {
R kb(0);
}
}
}
The check for equality of the argument x (or the element kK(x)[i] of arg x) to ns does not work as I expected.
q)`test set `:test 2: `test,1
`test
q)test ``a`b
000b
// should be 100b
How do I perform this comparison properly?