Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 85025 invoked from network); 28 Apr 2003 14:54:11 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 28 Apr 2003 14:54:11 -0000 Received: (qmail 14494 invoked by uid 97); 28 Apr 2003 14:56:11 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 14487 invoked from network); 28 Apr 2003 14:56:11 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 28 Apr 2003 14:56:11 -0000 Received: (qmail 84834 invoked by uid 500); 28 Apr 2003 14:54:08 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 84820 invoked from network); 28 Apr 2003 14:54:08 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 28 Apr 2003 14:54:08 -0000 Received: (qmail 38485 invoked by uid 1304); 28 Apr 2003 14:54:07 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 28 Apr 2003 14:54:07 -0000 Date: Mon, 28 Apr 2003 07:54:07 -0700 (PDT) From: Rodney Waldhoff To: Jakarta Commons Developers List Subject: Re: [functor] predicates In-Reply-To: Message-ID: <20030428074502.M33349@icarus.apache.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N You can use a process known as Currying to convert a binary function to a unary one. There are types in functor.adapater for binding a constant value to the left-side or right-side argument of BinaryFunction, BinaryPredicate or BinaryProcedure, yielding a UnaryFunction, UnaryPredicate or UnaryProcedure, respectively. For example, UnaryPredicate isLessThan7 = new RightBoundPredicate( new IsLessThan(), new Integer (7)); Hence, to select all the elements of myCollection less than 7, use: CollectionAlgorithms.select(myCollection.iterator(), isLessThan7); - Rod On Mon, 28 Apr 2003, Jason Horman wrote: > Many of the comparator predicates are BinaryPredicates. Should then not be > both binary and unary. For example, the IsLessThan predicate is strictly > binary, rendering it useless for > CollectionAlgorithms.select/reject/contains, etc. Or would it make more > sense to renamed the existing binary predicates to BinaryIsLessThan and > create a UnaryIsLessThan? > > -jason > jason@jhorman.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org