tokenize

here’s a function table to lex some strings:

q)a:“r2+d2”

q)f:an`o!({x in “red”};{x in “1234567890”};{x in “±”})

q)raze (key f)where each flip@:[value f;a]?

anoa`n

i bet there is a way to avoid the key and value calls.

or am i better off with this?

q)f:({x in “red”};{x in “1234567890”};{x in “±”})

q)raze an`o where each flip@:[f;a]?

anoa`n

how about this?

q)where each f@:/:a
a
n
o
a
n
q)

missed to raze:

q)raze where each f@:/:a
anoa`n

To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1499)

a more vectorized solution

q)r:-1_0,sums count each a:(“red”;“1234567890”;“±”);a:raze a
q)ano r bin a?"r2+d2" anoan

Cheers,
Attila
On 15 Oct 2012, at 23:05, wp wrote:

> missed to raze:
>
> q)raze where each f@:/:a
> anoan<br>&gt; <br>&gt; <br>&gt; On Mon, Oct 15, 2012 at 11:01 PM, wp <walter1003> wrote:<br>&gt;&gt; how about this?<br>&gt;&gt; <br>&gt;&gt; q)where each f@\:/:a<br>&gt;&gt; a<br>&gt;&gt; n<br>&gt;&gt; o<br>&gt;&gt; a<br>&gt;&gt; n<br>&gt;&gt; q)<br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; On Mon, Oct 15, 2012 at 10:51 PM, Jack Andrews <effbiae> =<br>wrote:<br>&gt;&gt;&gt; here's a function table to lex some strings:<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; q)a:"r2+d2"<br>&gt;&gt;&gt; q)f:ano!({x in “red”};{x in “1234567890”};{x in “±”})
>>> q)raze (key f)where each flip@:[value f;a]
>>> anoan<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; i bet there is a way to avoid the key and value calls.<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; or am i better off with this?<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; q)f:({x in "red"};{x in "1234567890"};{x in "+-"})<br>&gt;&gt;&gt; q)raze ano where each flip@:[f;a]
>>> anoa`n
>>>
>>>
>>> –
>>> 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-kdbplus@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> personal-kdbplus+unsubscribe@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/personal-kdbplus?hl=en.
>
> –
> 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-kdbplus@googlegroups.com.
> To unsubscribe from this group, send email to =
personal-kdbplus+unsubscribe@googlegroups.com.
> For more options, visit this group at =
http://groups.google.com/group/personal-kdbplus?hl=en.
>


based on attila’s version:

q)r:(raze a)!ano where count each a:("red";"1234567890";"+-") q)r"r2+d2" anoan

that’s nice
im telling you im getting stupid ;)