#Include "file.bi" type tally as string s as long l end type Sub quicksort(array() As String,begin As Long,Finish As Long) Dim As Long i=begin,j=finish Dim As String x =array(((I+J)\2)) While I <= J While array(I) < X :I+=1:Wend While array(J) > X :J-=1:Wend If I<=J Then Swap array(I),array(J): I+=1:J-=1 Wend If J >begin Then quicksort(array(),begin,J) If I X .l:I+=1:Wend While array(J).l < X .l:J-=1:Wend If I<=J Then Swap array(I),array(J): I+=1:J-=1 Wend If J >begin Then tallysort(array(),begin,J) If I 0 Then text = String(Lof(f), 0) Get #f, , text End If Close #f Return text End Function Function String_Split(s_in As String,chars As String,result() As String) As Long Dim As Long ctr,ctr2,k,n,LC=Len(chars) Dim As boolean tally(Len(s_in)) #macro check_instring() n=0 While n0 Then Redim Preserve result(1 To ctr+1) result(ctr+1)=Mid(s_in,k+1-ctr2,ctr2) End If Return Ubound(result) End Function Redim As String s() redim as tally t() dim as string p1,p2,deliminators dim as long count,jmp dim as double tm=timer Var L=loadfile("rosettalesmiserables.txt") L=lcase(L) 'get deliminators for n as long=1 to 96 p1+=chr(n) next for n as long=123 to 255 p2+=chr(n) next deliminators=p1+p2 string_split(L,deliminators,s()) quicksort(s(),lbound(s),ubound(s)) For n As Long=lbound(s) To ubound(s)-1 if s(n+1)=s(n) then jmp+=1 if s(n+1)<>s(n) then count+=1 redim preserve t(1 to count) t(count).s=s(n) t(count).l=jmp jmp=0 end if Next tallysort(t(),lbound(t),ubound(t))'sort by frequency print "frequency","word" print for n as long=lbound(t) to lbound(t)+9 print t(n).l,t(n).s next Print print "time for operation ";timer-tm;" seconds" sleep