Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 01DC5EAB8 for ; Mon, 7 Jan 2013 12:12:48 +0000 (UTC) Received: (qmail 76838 invoked by uid 500); 7 Jan 2013 12:12:46 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 76451 invoked by uid 500); 7 Jan 2013 12:12:46 -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 76416 invoked by uid 99); 7 Jan 2013 12:12:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jan 2013 12:12:45 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Ingemar.Stock@philotech.de designates 62.159.210.76 as permitted sender) Received: from [62.159.210.76] (HELO mail.philotech.net) (62.159.210.76) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jan 2013 12:12:38 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Struggling with erlang Date: Mon, 7 Jan 2013 13:12:06 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Struggling with erlang thread-index: Ac3s0DUXeMHGArQSThetgNQ3Gl4PCg== From: "Stock, Ingemar" To: X-Virus-Checked: Checked by ClamAV on apache.org Hey all, can somebody help me to translate this filter function into Erlang, pls? function(doc){ if(doc.type =3D=3D=3D "tile"){ return doc.key.length <=3D 8; }else{ return true; } } My first attempt was this, but I don't know how to do the "key.length = <=3D 8" check and I'm not sure if this works at all: fun({Doc}) -> case {proplists:get_value(<<"type">>, Doc), proplists:get_value(<<"key">>, Doc)} of {undefined, _} -> true; {_, undefined} -> true; {Type, Key} -> case {Type} of {<<"tile">>} -> true; _ -> false; end; _ -> true; end end. Thank you, Ingemar