View/Edit #29:uncrunch

Switch to edit mode.

Name(s): uncrunch
1:  "A simple run-length decompression routine, by Odo."
2:  "Args[1] is either a string, a list of strings, or a compressed list from $string_utils:crunch.  This verb returns the first two types, and returns the uncompressed version of the third."
3:  if (!(input = args[1]) || typeof(input) != $LIST || input[1] != this.tab)
4:    return input
5:  endif
6:  output = {}
7:  for line in (listdelete(input, 1))
8:    newline = ""
9:    while (index = index(line, "^"))
10:     newline = newline + line[1..index - 1]
11:     letter = line[index + 1]
12:     for repeat in [1..index(this.ascii, line[index + 2], 1)]
13:       newline = newline + letter
14:     endfor
15:     line = line[index + 3..$]
16:   endwhile
17:   output = {@output, newline + line}
18:   $command_utils:suspend_if_needed()
19: endfor
20: return length(output) == 1 ? output[1] | output
21: "Last modified by Dax (#789) on Mon Aug  7 21:46:46 2006 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Odo (#987)

You are not logged in.

[home | help | who | search | setup | code]