Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 80252 invoked from network); 22 Apr 2009 20:41:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Apr 2009 20:41:22 -0000 Received: (qmail 63563 invoked by uid 500); 22 Apr 2009 20:41:21 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 63485 invoked by uid 500); 22 Apr 2009 20:41:21 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 63475 invoked by uid 99); 22 Apr 2009 20:41:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2009 20:41:21 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of awolff@gmail.com designates 209.85.221.112 as permitted sender) Received: from [209.85.221.112] (HELO mail-qy0-f112.google.com) (209.85.221.112) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2009 20:41:14 +0000 Received: by qyk10 with SMTP id 10so382627qyk.13 for ; Wed, 22 Apr 2009 13:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=awgsAd+DUkC5lHFG3Oyj8at5Ky6ZObu9k511uFhIgho=; b=MMw5EgWkSsWA9r9tyt1tN9gonmvZPN1FgNLL6f5OTqA7PVXkfZjOHkMUGZwUv/N9n3 iOp5rRkjb3FmMAdzVAFAItir6hUjf2+HyVepWCFyBCf7/gNDsgdpkUSEGfmSR/I8cqDL YVxscHYBHP9g2P1gdt3p6Zmv9n+LAw7guaMYU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=EDbaeHK8yawlrFiVuZRqSt9nk4ARB6GdiykKGogZIwmsAI3gr6sONr/jcyINf0h0Oz 8lfSxveG+IJondaPc+yy7LKvpgtT6UhUyfY0yydtxw3ZsuijY+ByQ4TpRx38Lv5nC8BN AkiS9EYpYUtl9uG0WLuUkqujP5nwn8Nqy2uiA= MIME-Version: 1.0 Received: by 10.229.100.13 with SMTP id w13mr257840qcn.62.1240432853622; Wed, 22 Apr 2009 13:40:53 -0700 (PDT) In-Reply-To: References: <51fbc8f50904220655r2d05f439n1ac9b71784ef9baf@mail.gmail.com> <9acd6e550904220700m2657cca8sdf51dae370e84d48@mail.gmail.com> Date: Wed, 22 Apr 2009 13:40:53 -0700 Message-ID: Subject: Re: The sum function (used in reduce) From: Adam Wolff To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org It'd be great to make it so that _design docs can define helper functions too, so that two views can share a helper. A On Wed, Apr 22, 2009 at 7:25 AM, Zachary Zolton wrote: > I've also expressed interest in both: > > =A01) Adding/devising more helper functions > > =A02) Upgrading SpiderMonkey to JavaScript version 1.8 > > This would add a LOT features useful for succinct JavaScript Map/reduce c= ode: > =A0* More functional methods on Array objects, such as reduce() > =A0* Destructuring assignments > =A0* Short-cut Lambda notation (ooh la la!) > > Of course, SpiderMonkey 1.8 is still in RC1, however anyone who's been > using Firefox 3 has been exposed to it! > > On Wed, Apr 22, 2009 at 9:00 AM, Thomas Heller wrot= e: >> Hey, >> >> you can find it in COUCH_HOME/share/server/main.js >> >> sum =3D function(values) { >> =A0var rv =3D 0; >> =A0for (var i in values) { >> =A0 =A0rv +=3D values[i]; >> =A0} >> =A0return rv; >> } >> >> And no, its the only "helper" function. >> >> Regards, >> /thomas >> >> >> On Wed, Apr 22, 2009 at 3:55 PM, Rangachari Anand wr= ote: >> >>> I searched all over the wiki and did not see any description of the >>> sum function that can be called in the reduce method of >>> a view. I can guess what it does but a pointer to more >>> concrete information would be appreciated. >>> >>> There is only a passing reference to it in the page >>> http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views >>> >>> Are there any other handy functions that could be called from inside >>> map or reduce? >>> >>> Thanks >>> Rangachari Anand >>> >> >