Skip to content

Instantly share code, notes, and snippets.

@wolever
Created February 4, 2010 22:56
Show Gist options
  • Save wolever/295237 to your computer and use it in GitHub Desktop.
Save wolever/295237 to your computer and use it in GitHub Desktop.
// Accepts a bunch of lines then strips, from every line, the shortest prefix
// that is entirely whitespace and creates a 2D array.
// Find the smallest amount of whitespace before any line...
var minWhitespace:int = min(map(function(line:String):int {
return line.replace(/^([ \t]*).*/, "$1").length;
}, str.split("\n")));
// ... then strip it off and return an array of single characters.
var grid:Array = map(function(line:String):Array {
return map(line.charAt, range(minWhitespace, line.length));
}, str.split("\n"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment