Why does u $ v lead to a length error ? Please note u is without a back tick
have you read?..
http://code.kx.com/wiki/JB:QforMortals/casting\_and\_enumerations#Enumerations
The $ function is dyadic.
During the enumeration process of $…
If the x arg is a list of symbols, it expects the same number of lists of symbols as the y arg
1 to 1
q)u:a
bc;v:
ab
c;$[`u;v]
u$
ab
c
3 to 3
q)$[`u`u`u;flip 3#'v]
a b c
a b c
a b c
I’m going to assume the count of your v var is more/less than the count of u…this is why you get a length error. Below I have reproduced…
//Enumerate a list of 3 lists of symbols over 2 domains
q)$[u
u;flip 3#'v]
'length
//Enumerate a list of 2 symbols over a list of 3 symbols - this is what I think you will have in your example
q)v:a
b
q)u$v
'length
//Notice here if v and u would have had the same count you would have got type error due to it enumerating the y arg over each atom of the x arg
q)v:a
b`c
q)u$v
'type
HTH,
Sean
I have read that chapter. My question was very simple. Why do we need the bacjtick char before variable u in my expression
If you read the enumeration section carefully, you will see that it is simply a subset of casting. Copying direct example from the page Sean referred to, here is how you create a typed empty list:
L1:`int$() type L1 6h L2:`float$() type L2 9h L3:`symbol$() type L3 11h
Now, if you want to create a list of typed u, how would you do it? You guessed it right… `u$()