Re: Str-Kat
- Posted by Jim Brown <jbrown105 at l?nuxbu?dhist.net> May 30, 2008
- 720 views
Kat wrote: > > ken mortenson wrote: > > > > Kat wrote: > > > > > It would also be easier if Eu returned unused > > > memeory to the OS via some command or other > > > > I believe it does Kat. I believe I remember seeing free() routine? > > So it's only a matter of using allocate() and free()? No wonder it's not been > done yet! Where is the magic spell that makes compare() and equal() and > string[2] > and length(string) work, after you get allocate() and free() typed out? > > Kat --string.e --------------------- namespace string global function compare(atom a, atom b) integer i, ac, bc i = 0 ac = peek(a) bc = peek(b) while 1 do if ac > bc then return 1 elsif ac < bc then return -1 elsif (ac = bc) and (ac = 0) then return 0 else i = i + 1 ac = peek(a+i) bc = peek(b+i) end if end while end function global function equal(atom a, atom b) return compare(a,b) = 0 end function global function length(atom a) integer i i = 0 while peek(a+i) != 0 do i = i + 1 end while return i end function --string[2] is impossible to do currently, but there is this workaround global function slice(atom a, integer i) return peek(a+i) end function