Expand tabs (implement expand(1))
Ruby 161 145

Reads the tabstop specification on the first line of input.

i=t=[]
gets.scan(/(\+)?(\d+)/){t&lt;&lt;i=$2.to_i+($1?i:0)}
81.times{|j|t&lt;&lt;j*i}
while gets
$_.sub!$&amp;," "*(t.find{|s|s&gt;i=$`.size}-i)while~/\t/
print
end


edit: Added two lines that makes the last read tabstop repeat so that tabstop specifications of a single number also works correctly

i is a temporary variable for holding the last parsed tabstop. t is the list of tabstobs, parsed from the gets.scan line. For good measure we add 81 multiples of the last parsed tabstop. the while gets loop keeps going until there is no more input. For each line of input we substitute tabs for spaces, one tab at the time because the string moves as we add the spaces and we must recalculate the correct tabstop.