Look-and-say sequence: Difference between revisions

no edit summary
m (syntax highlighting fixup automation)
No edit summary
Line 2,221:
10 - 11131221133112132113212221
</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
local fn LookAndSay( testWord as CFStringRef ) as CFStringRef
NSUInteger i, length, times
CFMutableStringRef result = fn MutableStringWithCapacity(0)
unichar repeat = fn StringCharacterAtIndex( testWord, 0 )
times = 1
testWord = fn StringWithFormat( @"%@ ", fn StringSubstringFromIndex( testWord, 1 ) )
length = len(testWord)
for i = 0 to length - 1
unichar actual = fn StringCharacterAtIndex( testWord, i )
if ( actual != repeat )
MutableStringAppendFormat( result, @"%d%c", times, repeat )
times = 1
repeat = actual
else
times++
end if
next
end fn = fn StringWithString( result )
 
void local fn DoIt
NSUInteger i
CFStringRef numStr = @"1"
for i = 1 to i <= 15
NSLog( @"%@", numStr )
numStr = fn LookAndSay( numStr )
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
3113112221232112111312211312113211
1321132132111213122112311311222113111221131221
11131221131211131231121113112221121321132132211331222113112211
311311222113111231131112132112311321322112111312211312111322212311322113212221
</pre>
 
 
 
=={{header|Gambas}}==
715

edits