Removing last characters from string
[1/4] from: fuka::fuxoft::cz at: 5-Jan-2003 21:12
Is there a simpler way to remove last 2 characters from string than this: ?
str: head clear skip tail str -2
--
Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
----------------------------------------------------
My E-mail: [fuka--fuxoft--cz]
My Homepage: http://www.fuxoft.cz
My ICQ: 2745855
[2/4] from: sunandadh:aol at: 5-Jan-2003 15:46
Frantisek:
> Is there a simpler way to remove last 2 characters from string than this: ?
> str: head clear skip tail str -2
Simpler is subjective :-)
I'd write:
str: copy/part str -2 + length? str
Sunanda.
[3/4] from: joel:neely:fedex at: 5-Jan-2003 15:06
Hi, Frantisek,
The set-word isn't needed.
Frantisek Fuka wrote:
> Is there a simpler way to remove last 2 characters from string
> than this: ?
>
> str: head clear skip tail str -2
>
>> foo: "abcdef"
== "abcdef"
>> clear skip tail foo -2
== ""
>> foo
== "abcd"
The use of CLEAR modifies the series to which FOO refers, so you
don't need to set the result back into FOO. If you want to do
the removal and then immediately use the truncated value, then
prepending the HEAD will yield that value without the need for
another reference to (or setting of) FOO, as in
>> foo: "0123456"
== "0123456"
>> head clear skip tail foo -2
== "01234"
HTH!
-jn-
[4/4] from: tomc:darkwing:uoregon at: 5-Jan-2003 15:34
clear back back tail str
On Sun, 5 Jan 2003, Frantisek Fuka wrote: