Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: ztrumpet on February 10, 2010, 10:00:41 pm

Title: Efficient Sub-String Method
Post by: ztrumpet on February 10, 2010, 10:00:41 pm
Here's my favorite way of using sub(.
The idea of this is to use sub( and sum( in an odd manner.
ex:
:3->A //You want the third item
:{1,6,6,5,1,4,1 // 1 followed by the lengths of the Item. (Item 1 has a length of 6, Item 2 has a length of 6, Eeems has a length of 5... )
:sub("Item 1Item 2Eeems455556",sum(Ans,1,A),Ans(A+1 //sub(String,Add to get to spot,Length of Item

This results with the third item, "Eeems". ;D
I hope this helped someone.  What do you guys think?
Title: Re: Efficient Sub-String Method
Post by: Eeems on February 11, 2010, 12:04:34 am
Hmm, looks interesting, I'll have to test it...it might help with when I do string indexing.
Title: Re: Efficient Sub-String Method
Post by: Galandros on February 11, 2010, 07:45:57 am
Nice code.

I also like tricks with instring( and sub( together. They are pretty efficient.