[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
string functions
- To: T-Discussion at YALE
- Subject: string functions
- From: Chris Riesbeck <Riesbeck at YALE>
- Date: Thu ,7 May 82 16:46:00 EDT
It seems to be agreed that T will need some decent string functions
and top on my list is a substring function. UCILisp has one which
I like a lot:
(SUBSTRING string m n)
takes a substring of string from m to n. Note that this is not
interpreted as taking n characters starting from position m. UCILisp
used to do that, and it loses. But even better is that UCILisp allows
m and n to be negative, in which case they count from the right. The
most common use of this is
(SUBSTRING string 1 -1)
which strips off the last character. Us natural language-hackers really
appreciate that. Without it, you are constantly grabbing the string
length so you can decrement it.
The problem? This conflicts with 0-based indexing, unless you allow
-0 to be different than 0, a bag of worms I assume no one wants to
open.
A solution? Abandon 0-based for substring -- the -1 feature is just
too useful.
Any other ideas?
-------