MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Position of element in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16376] Re: Position of element in a list
  • From: Stephen P Luttrell <luttrell at signal.dra.hmg.gb>
  • Date: Thu, 11 Mar 1999 02:16:47 -0500
  • Organization: Defence Evaluation and Research Agency
  • References: <7bt665$ndn@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

>I want to find the Position[] of negative elements in a list. The obvious
>methods do not work:
>
>Position[{-1, 3, -2, 1}, -_]
>
>and
>
>Position[{-1, 3, -2, 1}, -x_]
>
>return
>
>{}
>
>So how do I perform this apparently simple task?


This works:

Position[{-1, 3, -2, 1}, _?(#<0&)]

The pattern _?(#<0&) includes the pure function #<0& which tests each object
in the list for negativity.

=====================================================

Stephen P Luttrell
Signal Processing and Imagery Department
DERA Malvern, St.Andrew's Road
Malvern, United Kingdom, WR14 3PS

+44 (0)1684 894046 (tel)
+44 (0)1684 894384 (fax)
luttrell at signal.dera.gov.uk (email)




  • Prev by Date: Re: Multiply a constant to a matrix column
  • Next by Date: Re: Win95 and quicktime
  • Previous by thread: Re: Position of element in a list
  • Next by thread: Re: Position of element in a list