Received: from spf5.us4.outblaze.com (spf5.us4.outblaze.com [205.158.62.27]) by sdf.lonestar.org (8.12.10/8.12.10) with ESMTP id iACApIWN029777 for ; Fri, 12 Nov 2004 10:51:19 GMT Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by spf5.us4.outblaze.com (Postfix) with ESMTP id 3BC3E77846 for ; Fri, 12 Nov 2004 10:51:21 +0000 (GMT) Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSZA3-0007V8-7q for migo@homemail.com; Fri, 12 Nov 2004 06:00:11 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CSYwK-0002zn-En for gnu-arch-users@gnu.org; Fri, 12 Nov 2004 05:46:01 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CSYwH-0002zE-Jq for gnu-arch-users@gnu.org; Fri, 12 Nov 2004 05:45:58 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CSYwC-0002yy-Ed for gnu-arch-users@gnu.org; Fri, 12 Nov 2004 05:45:56 -0500 Received: from [193.131.176.58] (helo=cam-admin0.cambridge.arm.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CSYn7-0002sC-V6 for gnu-arch-users@gnu.org; Fri, 12 Nov 2004 05:36:30 -0500 Received: from cam-mail2.cambridge.arm.com (cam-mail2.cambridge.arm.com [10.1.127.39]) by cam-admin0.cambridge.arm.com (8.12.10/8.12.10) with ESMTP id iACAZgso028005; Fri, 12 Nov 2004 10:35:42 GMT Received: from localhost.localdomain (cmarinas@pc1117.cambridge.arm.com [10.1.69.160]) by cam-mail2.cambridge.arm.com (8.9.3/8.9.3) with ESMTP id KAA03409; Fri, 12 Nov 2004 10:36:21 GMT To: Dustin Sallings References: <20041107234609.7bf0abfe@delta.hk.office.outblaze.com> <1099995711.2900.84.camel@stargate> <20041110204049.GD5978@suffields.me.uk> <20041111093245.GY721@vagabond> <20041111100931.GB11392@hezmatt.org> <6E1DC26B-340C-11D9-9D7F-000393CFE6B8@spy.net> <20041111222531.GD23560@hezmatt.org> From: Catalin Marinas Date: Fri, 12 Nov 2004 10:37:02 +0000 In-Reply-To: (Dustin Sallings's message of "Thu, 11 Nov 2004 15:24:20 -0800") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: gnu-arch-users@gnu.org, Matthew Palmer Subject: [Gnu-arch-users] Re: darcs vs tla X-BeenThere: gnu-arch-users@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: a discussion list for all things arch-ish List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: gnu-arch-users-bounces+migo=homemail.com@gnu.org Errors-To: gnu-arch-users-bounces+migo=homemail.com@gnu.org Status: RO Content-Length: 1206 Lines: 35 Dustin Sallings writes: > IN some cases, yeah, quite a bit. For example, how many lines > of the equivalent of this (contrived because I'm too lazy to look for > anything better) example in C? > > # Create a hash table mapping all of the md5s of the word list > to the words in the list > ht = dict([ (md5.md5(word).hexdigest(), word) for word in > words]) I wouldn't compare Python with C (maybe assembler with C is a better comparison) but Python with C++. C++ does not support list comprehension but you can probably write the above in a single line (exept for the variable declarations) using the STL library: for_each(words.begin(), words.end(), add_to_dict(dict)); You would need the add_to_dict functor (callable object) to get the md5 sum (from a library) and set dict[md5sum] = word. If you really want to write this on a single line, you could probably use the Boost library's lambda expressions (http://boost.org/libs/lambda/doc/index.html). Catalin _______________________________________________ Gnu-arch-users mailing list Gnu-arch-users@gnu.org http://lists.gnu.org/mailman/listinfo/gnu-arch-users GNU arch home page: http://savannah.gnu.org/projects/gnu-arch/