1. Re: Kat and sequence ie EU vs Perl

From: Kat <KSMiTH at PELL.NET>

> Subject: Re: Kat and sequence ie EU vs Perl
>
> Simply put, the token functions allow a sequence to be handled a distance
> above bytes,, and in chunks, like words. That way, you need not deal with
> bytes/chars in your code, cause as a human, i don't either, i use words.
In
> a sentence like "I am a cat" , "cat" would be a token, number 4, to be
> precise. To see if a character in a game is mentioned, use istok(). Why?
> `Cause in the sentence "hand me a catalog", istok(s,"cat") will return
zero
> or false or null, because "cat" is not a word in that sentence. With
> instok(), if the code calls for the sentence to be changed for some
reason,
> findtok() can find catalog, and instok() can put "red" in front of it for
> instance. Tokcount() can tell you the word count, gettok() can return a
> specific word or range of words. These are string handling functions,
> working on the unchanged sequences, altho the sequence *can* be tokenized
> and sent back as {{word#1}{word#2}{word#3}{etc}}, and the indexing you do
> with the tok calls will not crash if under or over indexed. What if you
are
> playing with urls,, and want the ip of the www.addy.com/owner/page.htm?
You
> dns the gettok(ip,1,'/') , the gettok returned the www.addy.com part of
the
> url. So you can parse the line based on spaces, or carets, or dots, or
> commas, or parse a paragraph by periods, or a sequence by specific bytes.
By
> nesting a couple gettok() , you can parse the "egghead" out of
> Hal9000!egghead at s100.tom.coslink.net , or the "s100" or the "coslink" etc.
> Using words. By using reptok, you can change the "s100" to "pdq", or
remtok
> will remove it.
>
> The way i see it, *unrestricted* strings are one step above sequences,
even
> if they stay sequences, and we only *handle* them as strings. See how a
few
> choice words makes it easier to parse info out of a series of bytes? smile
>
> Makes coding so much easier when your mind is on the words and how they
> relate to each other, and not the index of the start of the possible word
in
> a sequence of bytes.

Thanks, Kat, for a clear explanation. There are obviously a lot of uses for
library functions like the above. There is no language limitation that
prevents
these from working with Euphoria, all we need is someone to write an
include.
Volunteers?

Irv

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu