Anadromes: Difference between revisions

imported>Chinhouse
No edit summary
Line 438:
}
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="future basic">
 
begin globals
ptr gwordsPtr
uint32 gfilen
end globals
 
local fn loadDict
window 1, @"Anadromes",(0,0,209,502)
CFURLRef url = fn URLWithString( @"file:///Applications/FutureBasic/words.txt" )
if ( url )
open "I", 1, url
gfilen = lof( 1 )
gwordsPtr = fn malloc( gfilen )
read file 1, gwordsPtr, gfilen
close
end if
end fn
 
local fn anadromes
uint32 r, i, top, bot, med, count = 0
CFStringRef string = lcase(fn StringWithBytes( gwordsPtr, gfilen, NSASCIIStringEncoding ))
CFArrayRef array = fn StringComponentsSeparatedByString( string, @"\n" )
: array = fn arraySortedarrayUsingSelector( array, @"caseInsensitiveCompare:" )
print
for r = 0 to len(array)-1
if len( array[r] ) < 7 then continue
string = @""
for i = 0 to len(array[r]) - 1
string = fn StringByAppendingString( mid( array[r],i,1 ), string )
next
if fn StringIsEqual( array[r], string ) then continue
bot = r+1 : top = len( array )-1
while ( top - bot ) > 1
med = ( bot + top )>>1
select fn StringCompare( string, array[med] )
case NSOrderedAscending : top = med
case NSOrderedDescending : bot = med
case else : count++
print ,count,array[r];left( @" ",9-len(string) );string
break
end select
wend
next
end fn
 
fn loadDict
CFTimeInterval t = fn CACurrentMediaTime
fn anadromes
printf @"\t\t%.3f secs",fn CACurrentMediaTime - t
 
handleevents
</syntaxhighlight>
{{out}}
[[File:32 Anadromes.png]]
 
=={{header|Haskell}}==
68

edits