1. RE: Faster..less memory
- Posted by jordah at btopenworld.com Dec 21, 2002
- 538 views
Hi Kat, Just wondering what did u mean by extra tricks? the code below is a real memory and timesaver and if you explain exactly what you want your deparse() to do, i can do some changes and have a very fast and less memory consuming routine. Also, incase u don't like it? could u make 2 versions of deparse()? i really want people to start using that routine especially for those that handle large data... Maybe i should stop, bye Jordah Kat wrote: > On 24 Oct 2002, at 11:55, jordah ferguson wrote: > > > > > Hi all, > > for those of you who use strtok routines. here is a faster deparse that > > uses 4 times less memory. i used to get my program running out of memory > > > > using the old routine. > > > > Enjoy, AND ladies and gentlemen, please start posting interesting code > > fragments you come up with. cause many small cool routines are ignored > > in bulky source code > > > > Jordah Ferguson > > Note this won't support the current strtok-v2 release, which allows > deparsing > on multiple separators at once. Neither will it support v3, which has > another > trick,, err, ability. > > Kat > > > function deparse(sequence s,integer c) > > integer L1,L2,X1,X2 > > sequence R > > atom M > > L1 = length(s) > > if L1 then > > L2 = (L1 - 1) > > for n = 1 to L1 by 1 do > > L2 = L2 + length(s[n]) > > end for > > M = machine_func(16, L2) > > X1 = 0 > > for n = 1 to L1 by 1 do > > R = s[n] > > X2 = X1 + length(R) > > poke(M + X1,R) > > poke(M + X2,c) > > X1 = X2 + 1 > > end for > > R = peek({M,X2}) > > machine_proc(17,M) > > return R > > end if > > return s > > end function > > > >
2. RE: Faster..less memory
- Posted by Kat <gertie at PELL.NET> Dec 22, 2002
- 553 views
On 21 Dec 2002, at 13:43, jordah at btopenworld.com wrote: > > Hi Kat, > > Just wondering what did u mean by extra tricks? the code below is a > real memory and timesaver and if you explain exactly what you want your > deparse() to do, i can do some changes and have a very fast and less > memory consuming routine. It has to do with the declarations at the start: function deparse(sequence s,integer c) You could look at the latest release of strtok v2.1, i did ask who wanted it over a week ago, and only Derek replied, so i made no more changes. It's on the webpage http://www.pell.net/warning/ai/strtok-v2-1.html I was thinking of adding other things, but as i don't need them, and no one has suggested or asked for them, i didn't. The upgrade of v2 to v2.1 was to add things i need. I know of only two other people using the lib. Kat > Also, incase u don't like it? could u make 2 versions of deparse()? i > really want people to start using that routine especially for those that > handle large data... > > Maybe i should stop, bye > > Jordah > Kat wrote: > > On 24 Oct 2002, at 11:55, jordah ferguson wrote: > > > > > > > > Hi all, > > > for those of you who use strtok routines. here is a faster deparse that > > > uses > > > 4 times less memory. i used to get my program running out of memory > > > > > > using the old routine. > > > > > > Enjoy, AND ladies and gentlemen, please start posting interesting code > > > fragments you come up with. cause many small cool routines are ignored in > > > bulky source code > > > > > > Jordah Ferguson > > > > Note this won't support the current strtok-v2 release, which allows > > deparsing > > on multiple separators at once. Neither will it support v3, which has > > another > > trick,, err, ability. > > > > Kat > > > > > function deparse(sequence s,integer c) > > > integer L1,L2,X1,X2 > > > sequence R > > > atom M > > > L1 = length(s) > > > if L1 then > > > L2 = (L1 - 1) > > > for n = 1 to L1 by 1 do > > > L2 = L2 + length(s[n]) > > > end for > > > M = machine_func(16, L2) > > > X1 = 0 > > > for n = 1 to L1 by 1 do > > > R = s[n] > > > X2 = X1 + length(R) > > > poke(M + X1,R) > > > poke(M + X2,c) > > > X1 = X2 + 1 > > > end for > > > R = peek({M,X2}) > > > machine_proc(17,M) > > > return R > > > end if > > > return s > > > end function > > > > > > > > >
3. RE: Faster..less memory
- Posted by thomas at columbus.rr.com Dec 22, 2002
- 528 views
-- kat said -- > I know of only two other people using the lib. Actually, I have used it a bit as well. I'd love to see some more updates, although I can't think of anything that it *must have*. If you have a few ideas for things to add, I think you should definitely go ahead and add them (as long as it's not keeping you from working on other, more important projects). Even if we don't know that we need it, that doesn't mean we can't find a use for it tomorrow. :) Cheers, ~!tar!~
4. RE: Faster..less memory
- Posted by jordah at btopenworld.com Dec 22, 2002
- 532 views
Hi kat, Sorry, i'm unable to look at anything because my computer is broken so i have to use the library computers which filter any downloads,... so whatever code i'm writing next is just an assumption of what ur deparse does and is not guranteed to work.. 1) i assume that string c is the multiple delimeter in form eg {x,y,z} or a valid character delimeter function deparse(sequence s,object c) integer L1,L2,X1,X2,Sk sequence R atom M L1 = length(s) if L1 then Sk = 1 if sequence(c) then Sk = length(c) end if L2 = ((L1-1)*Sk) for n = 1 to L1 by 1 do L2 = L2 + length(s[n]) end for M = machine_func(16, L2) X1 = 0 for n = 1 to L1 by 1 do R = s[n] X2 = X1 + length(R) poke(M + X1,R) poke(M + X2,c) X1 = X2 + Sk end for R = peek({M,X2}) machine_proc(17,M) return R end if return s end function it is untested though should work... Jordah Kat wrote: > On 21 Dec 2002, at 13:43, jordah at btopenworld.com wrote: > > > > > Hi Kat, > > > > Just wondering what did u mean by extra tricks? the code below is a > > real memory and timesaver and if you explain exactly what you want your > > deparse() to do, i can do some changes and have a very fast and less > > memory consuming routine. > > It has to do with the declarations at the start: > function deparse(sequence s,integer c) > > You could look at the latest release of strtok v2.1, i did ask who > wanted it > over a week ago, and only Derek replied, so i made no more changes. It's > on > the webpage http://www.pell.net/warning/ai/strtok-v2-1.html > I was thinking of adding other things, but as i don't need them, and no > one > has suggested or asked for them, i didn't. The upgrade of v2 to v2.1 was > to > add things i need. I know of only two other people using the lib. > > Kat > > > Also, incase u don't like it? could u make 2 versions of deparse()? i > > really want people to start using that routine especially for those that > > > > handle large data... > > > > Maybe i should stop, bye > > > > Jordah > > Kat wrote: > > > On 24 Oct 2002, at 11:55, jordah ferguson wrote: > > > > > > > > > > > Hi all, > > > > for those of you who use strtok routines. here is a faster deparse that > > > > uses > > > > 4 times less memory. i used to get my program running out of memory > > > > > > > > using the old routine. > > > > > > > > Enjoy, AND ladies and gentlemen, please start posting interesting code > > > > fragments you come up with. cause many small cool routines are ignored > > > > in > > > > bulky source code > > > > > > > > Jordah Ferguson > > > > > > Note this won't support the current strtok-v2 release, which allows > > > deparsing > > > on multiple separators at once. Neither will it support v3, which has > > > another > > > trick,, err, ability. > > > > > > Kat > > > > > > > function deparse(sequence s,integer c) > > > > integer L1,L2,X1,X2 > > > > sequence R > > > > atom M > > > > L1 = length(s) > > > > if L1 then > > > > L2 = (L1 - 1) > > > > for n = 1 to L1 by 1 do > > > > L2 = L2 + length(s[n]) > > > > end for > > > > M = machine_func(16, L2) > > > > X1 = 0 > > > > for n = 1 to L1 by 1 do > > > > R = s[n] > > > > X2 = X1 + length(R) > > > > poke(M + X1,R) > > > > poke(M + X2,c) > > > > X1 = X2 + 1 > > > > end for > > > > R = peek({M,X2}) > > > > machine_proc(17,M) > > > > return R > > > > end if > > > > return s > > > > end function > > > > > > > >
5. RE: Faster..less memory
- Posted by jordah ferguson <jorfergie03 at yahoo.com> Oct 28, 2002
- 558 views
hi Kat, > Note this won't support the current strtok-v2 release, which allows > deparsing > on multiple separators at once. Neither will it support v3, which has > another > trick,, err, ability. > > Kat hi Kat, Actually, that is a very easy hack. The main point of this code fragment was to simulate how things would be if we had a STRING type in Euphoria. Faster & less memory!! if the routine, doesn't make it to strtok v3 is not a main concern, just the fact that its better in all ways matters :) i'll update it to conform with that in ver 2.0 thx. Jordah > > function deparse(sequence s,integer c) > > integer L1,L2,X1,X2 > > sequence R > > atom M > > L1 = length(s) > > if L1 then > > L2 = (L1 - 1) > > for n = 1 to L1 by 1 do > > L2 = L2 + length(s[n]) > > end for > > M = machine_func(16, L2) > > X1 = 0 > > for n = 1 to L1 by 1 do > > R = s[n] > > X2 = X1 + length(R) > > poke(M + X1,R) > > poke(M + X2,c) > > X1 = X2 + 1 > > end for > > R = peek({M,X2}) > > machine_proc(17,M) > > return R > > end if > > return s > > end function > > > >