https://learninghub.kx.com/forums/topic/like-comparison
Hi:
not sure why for the below two like comparison, the first one returns 1 and second type error? given both are comparing a symbol on the left to its equivalent in string.
`IBM like "IBM"
`t like "t"
thanks,
it does not get shown properly but IBM and t should be symbol type,
like takes a string on the right. "IBM" is a string. "t" is not a string but a character - this is a quirk in the syntax. If you want to have a one-character string you have to use enlist, in this case enlist"t".
q)type"t" // t is a character atom - 'like' expects a character vector
-10h
q)type"IBM" // IBM is a character vector
10h
q)type enlist "t" // You can enlist an atom to be a single item vector
10h
q)type (),"t" // (), is useful as a conditional enlist. It enlists the atom
10h
q)type (),"IBM" // It does not enlist the vector
10h