This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //flatten current level of array or arguments object | |
| var flatten = function(input, shallow, strict, startIndex) { | |
| var output = [], idx = 0; | |
| for (var i = startIndex || 0, length = getLength(input); i < length; i++) { | |
| var value = input[i]; | |
| if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { | |
| if (!shallow) value = flatten(value, shallow, strict); | |
| var j = 0, len = value.length; | |
| output.length += len; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def flatten(nested): | |
| # turn [1, [2, [3,4]], 5] to [1,2,3,4,5] | |
| flat = list() | |
| def flatten_in(nested, flat): | |
| for i in nested: | |
| flatten_in(i, flat) if isinstance(i, list) else flat.append(i) | |
| return flat | |
| flatten_in(nested, flat) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2.7 | |
| from string import Template | |
| import xml.sax | |
| import pprint | |
| import re | |
| import sys | |
| import collections | |
| class PropertyHandler( xml.sax.ContentHandler ): |