--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To post to this group, send email to personal...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.
if q is not so strong here, lex (or flex) will do a good
job at matching these sort of patterns. from q, you can
generate a lex file (call it l.l) that looks like:
%{
long n=0;
main()
{for(;yylex()>0;);
printf("counted %ld matches\n",n);
return 0;
}
%}
%%
"how fast" n++;
"perform this" n++;
"job" n++;
.
/**** EOF *****/
and build your scanner and run with test input:
$ flex -o n.c n.l && gcc n.c -o n -lfl && echo "how fast does it job
question?" |./n
counted 2 matches
ta, jack.
is not really faster, but less code
and by just looking at this it should be relatively obvious
that it won't be easy to find a faster expression if any
an idea would be doing something like this
q)l:(`int$())!`int$()
q)l[x]+:1
but that is actually slower
you cannot splay dictionaries
but you could just write down a two-column table and use that
Attila
it's vaguely useful, but a lot of things have changed in k4
your best bet is to start reading q.k and working out k equivalents to
everything you write in q
(and conversely whenever you break inside a k function stop and try to
figure out exactly how it works)
some things convert very easily, e.g. "count each group x" from above is "#:'=x"
some things are harder :)