Run-length encoding: Difference between revisions

m
→‎{{header|Sidef}}: modified the code to work with the latest version of Sidef
m (→‎{{header|Sidef}}: modified the code to work with the latest version of Sidef)
Line 3,513:
func decode(str) {
str.gsub(/(\d+)(.)/, {|a,b| b * a.to_i });
};</lang>
{{out}}
<pre>12W1B12W3B24W1B14W</pre>
Line 3,525:
var chars = str.chars;
var r = '';
0 .. (chars.len/2 - 1 -> int) .range.each { |i|
r += (chars[2*i + 1] * strchars[2*i].ord);
};
return r;
};</lang>
{{out}}
<pre>"\fW\1B\fW\3B\30W\1B\16W"</pre>
2,747

edits