this must be easier than i'm making it...

q)(1#“<”)~/:0N!x:-4!“<< >> <> == <= >=”

(,“<”;,“<”;," “;”>>“;,” “;”<>“;,” “;,”=“;,”=“;,” “;”<=“;,” “;”>=")

1100000000000b

-4! splits a string into tokens.

it conveniently handles <=, >=, <> and >>, but not << or ==.

what magic will ‘fix’ -4! so that i get << and == tokens as well as all other tokens?

ta, jack

I probably missed the whole point of the question, but what’s wrong with vs?

" " vs “<< >> <> == <= >=”

a more true to life example:


q)x:“if(x<<y||t==u)f();”

q)(1#'“<=”)~:/:-4!x

00b

00b
00b
10b
10b
00b
00b
00b
00b
01b
01b
00b
00b
00b
00b
00b
00b

 -4!  splits a string into Q Tokens (!!).

and obvisously  << and == are no q tokens. 

strangely >> is one, no idea why..

but there is nothing you can do. this is just how q works ;)

== is of course no q token, as comparison is done by a single =.

>=, <=, =, <>  are q comparison operations

i have no idea what >> is doing..

Something like this maybe? It’s pretty brutal, but it seems to work (I think)

q)tokenize:{[tokens;str](first[r],enlist last r:{$[(t:x[1],y) in z;(x 0;t);(x[0],enlist x 1;y,())]}[;;tokens]/[(();());str]) inter tokens}                                                                  

q)tokenize[" " vs “if << || == f”;“if(x<<y||t==u)f();”]                                                                                                                                                     

“if”

“<<”

“||”

“==”

,“f”

q)tokenize[" " vs “<< >> < > <> == <= >= =”; “<< >> < <> == <= >= f=”]                                                                                                                                      

“<<”

“>>”

,“<”

“<>”

“==”

“<=”

“>=”

,“=”

On Tuesday, October 11, 2016 at 3:12:17 PM UTC+1, Markus Sieber wrote:

 -4!  splits a string into Q Tokens (!!).

and obvisously  << and == are no q tokens. 

strangely >> is one, no idea why..

but there is nothing you can do. this is just how q works ;)

== is of course no q token, as comparison is done by a single =.

>=, <=, =, <>  are q comparison operations

i have no idea what >> is doing..

It appears >> has the same definition as <>

q)>>

~=

q)<>

~=

i think i found the key..

,/‘(&~((|,)’:x)in(“!=”;“||”))_x:-4!“alpha!=b||c”

(“alpha”;“!=”;,“b”;“||”;,“c”)