Your “q version” is actually a hybrid between k and q. A more q-native interpretation would look like:
rotate2:{$[0h>type y;'`rank;98h<type y;'`type;count y;raze reverse(0;x mod count y)_y;y]}
The whole function is a conditional with multiple branches. The part you crossed out is just a check if the list is empty, in which case we don’t bother with calculating the rotated version, we just return the original empty list. You seem to have broken up the conditional in your “q” version even though it is still possible to use the multi-branch version.
Watch out The q language is implemented as a DSL embedded in the k4 programming language. The latter is exposed infrastructure. It is neither supported nor documented, and its use is deprecated and in production code, strongly deprecated.
Huh now I see what youre up to: implementing rotate in q.
This reminds me of a category of puzzle that used to be popular in qs ancestor language APL, called dead key questions. The premise was always that a certain key on your keyboard was not working; how do you code around it?
APL primitives are mostly variadic: they can be applied as either unaries or binaries, usually with related semantics. And they are (almost) all single characters, which is what gives the dead key problem its bite. For example, rotate and reverse in q are in APL the binary and unary forms of ?
l?2 3 5 7 11
?l 11 7 5 3 2
2?l 5 7 11 2 3
In k, operators are similarly variadic; q replaces the unary forms with keywords. Like k itself, the unary forms of the operators are considered exposed infrastructure: use the q keywords instead. The (#) you asked about is, as P鴥r advises, in q written as count.