Re: String utility changes/additions

Raymond Martin <[email protected]> Tue, 21 Mar 2006 18:38:53 +0000
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
Hi Leon,

> > In there we have:
> >  glob
> >  split-words 
> >  merge-words
> >  read-lines 
> >  write-lines
> >  #P
> 
> These were written by Yann to match the semantics and the names of unix shells.
> This is obvious for <glob>, <split-words> and <merge-words>. 
> I am unsure about the <read-lines>/<write-lines> thing.
> 
> One could make more general string utilities available
> and reimplement these using the more general facilities.
> The question is to define what general facilities should be available.
> There are already some string utilities in sysenv.lsh 
> (stripl, stripr, regex-rseek, regex-split, etc..) whose design 
> is questionable.  Too many of them, too hard to remember.


Right, generalizing these functions is exactly my point in moving/fixing these.
As well, to try to put functions which are somewhat spread out in the code/docs
under appropriate sections.

The only real change besides names/locations is that spilt-words becomes:

(de tokenize (s &optional delims)
  (regex-split 
    (concat "[^" (or delims "\t ") "]+") s) )

With the drawback that not all delimiters can simply be passed in (some need escaping
and others just cannot be used in this overly simplistic function). The pair '[' and ']'
can't be used with the regex here (tried a number of times, but I have not done that
much with regular expressions to date).

Another function that could be added then would be something like:

(de word-tokenize (s)
  (tokenize s 
    " \t0-9<>,.!?;:/'\"\\{\\}\\\\|~@#$%^&*\\(\\)_=+-" ))


Raymond
__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642