Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| function(key, values, rereduce) { | |
| Array.prototype.unique = function() { | |
| var a = []; | |
| var l = this.length; | |
| for(var i=0; i<l; i++) { | |
| for(var j=i+1; j<l; j++) { | |
| // If this[i] is found later in the array | |
| if (this[i] === this[j]) | |
| j = ++i; | |
| } |
| function chunk(a, s){ | |
| for(var x, i = 0, c = -1, l = a.length, n = []; i < l; i++) | |
| (x = i % s) ? n[c][x] = a[i] : n[++c] = [a[i]]; | |
| return n; | |
| } |
Here's what I do after I do a fresh install of Lion. Things are sorta grouped by type.
| from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler | |
| from SocketServer import ThreadingMixIn | |
| import threading | |
| import requests | |
| class Handler(BaseHTTPRequestHandler): | |
| def __init__(self, request, client_address, server): | |
| print "Init!" | |
| self.protocol_version = 'HTTP/1.1' | |
| BaseHTTPRequestHandler.__init__(self, request, client_address, server) #http://www.mlsite.net/blog/?p=80 |
Original discussion began on Twitter and can be found by starting here and here. Discussion was continued on es-discuss mailing list in the thread Pure win: Array.from and Array.of
Update Nov. 3, 2011
Official strawman has been posted: http://wiki.ecmascript.org/doku.php?id=strawman:array_extras
| ($=document.createElement('script')).src='http://j.mp/jqueryjs';(document.getElementsByTagName('head')[0]).appendChild($) |