Can anyone explain why when assigning ‘do’ do I not get an 'assign error or any error for that matter?
do is restricted word in q.
Check .Q.res for other similar words.
you can however set ‘do’ value using:
.q.do:`asdf
‘do’ is control statement and if you use do in your program then the statement will execute at least once.
and if you use while as control statement then first it will check the condition and according to condition whether it will execute.
Thanks
Hari
That’s an interesting one. It seems that since some of the restricted words (such as if, while, do) must be followed by square brackets, q knows that when you type if[…;…] then you’re using the “if” construct but if you use “if” in a different context then it will reference it as a variable.
q)count:`abc
'assign
q)do:6
q)do
6
q)do[4;show “hello”]
“hello”
“hello”
“hello”
“hello”
q)
q)do+5
11
q)if:1.5
q)
q)if
1.5
q)
q)if[1b;show “hello”]
“hello”
q)value (+;if;2.3)
3.8
On the other hand if you were able to reassign “count” and you just typed “count”, then q wouldn’t know whether you’re using the function count or referencing the hypothetical variable “count”.
Nevertheless, reassigning these is obviously not at all recommended!!
It’s funny what statements actually turn out to be valid
q)while:1b
q)do[while;if[while;if[while;if:while];do:if]]
q)if[do=while;do[while;show if]]
1b
oh crap it looks I should read the original post before answering…:S