Odd words: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
No edit summary |
||
Line 545: | Line 545: | ||
starvation ---> train |
starvation ---> train |
||
upholstery ---> posey</pre> |
upholstery ---> posey</pre> |
||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
include "NSLog.incl" |
|||
local fn WordsPassingTest( array as CFArrayRef, obj as CFTypeRef, index as NSUInteger, stp as ^BOOL, userData as ptr ) |
|||
end fn = ( len(obj) > 4 ) |
|||
local fn WordList as CFArrayRef |
|||
CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" ) |
|||
CFStringRef string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL ) |
|||
CFArrayRef wordList = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet ) |
|||
IndexSetRef indexes = fn ArrayIndexesOfObjectsPassingTest( wordList, @fn WordsPassingTest, NULL ) |
|||
wordList = fn ArrayObjectsAtIndexes( wordList, indexes ) |
|||
end fn = wordList |
|||
void local fn OddWords |
|||
dispatchglobal |
|||
CFArrayRef wordList = fn WordList |
|||
CFStringRef string |
|||
long i |
|||
for string in wordList |
|||
CFMutableStringRef wd = fn MutableStringWithCapacity(0) |
|||
for i = 0 to len(string) step 2 |
|||
MutableStringAppendString( wd, mid(string,i,1) ) |
|||
next |
|||
if ( len(wd) > 4 ) |
|||
if ( fn ArrayContainsObject( wordList, wd ) ) |
|||
NSLog(@"%@",wd) |
|||
end if |
|||
end if |
|||
next |
|||
dispatchend |
|||
end fn |
|||
fn OddWords |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
brain |
|||
cider |
|||
cried |
|||
grata |
|||
hades |
|||
plain |
|||
point |
|||
slain |
|||
slain |
|||
sight |
|||
saute |
|||
spree |
|||
spree |
|||
trial |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |