Run-length encoding: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 2,836:
<syntaxhighlight lang=FutureBasic>
 
Dynamic a(1, 1) as Short // Self-fulfilling array, so don't need width and height
 
 
local fn encode( string as CFStringRef) as CFStringRef
Line 2,883 ⟶ 2,884:
for i = 0 to len( string ) - 2 // Final char is !
ch = mid( string, i, 1 )
if intval( ch ) == 0 // Not o, b, $
rl = 1
else
Line 2,890 ⟶ 2,891:
ch = mid( string, i, 1 )
end if
select ch // Decode character as:
case @"$" : f = -1 // - new line
case @"b" : f = 0 // - dead
case @"o" : f = 1 // - live
case else : // Ignore
end select
Line 2,900 ⟶ 2,901:
x = 0 : y ++ : v = 0 // New line
else
a(x, y) = f : x ++ : v ++ : if v > w then w = v
x ++ : v ++ : if v > w then w = v
end if
next // run
60

edits