Re: Weird Position[list,form] behavior when used inside of Module.

• To: mathgroup at smc.vnet.net
• Subject: [mg117065] Re: Weird Position[list,form] behavior when used inside of Module.
• From: DrMajorBob <btreat1 at austin.rr.com>
• Date: Wed, 9 Mar 2011 06:56:57 -0500 (EST)

```You have mismatched brackets, and no way of testing the code without F.

But here's a possibility:

f = Interpolation at {{.1, 5.3}, {.2, 5.4}, {.3, 5.2}, {.4, 5.9}};

Module[{A, B, RETURN},
A = Table[f@i, {i, {.1, .2, .3, .4}}];
B = Position[A, Min[A]];
RETURN = B]

{{3}}

Better:

Module[{a = Table[f@i, {i, {.1, .2, .3, .4}}]}, Position[a, Min[a]]
]

{{3}}

Or better again:

Module[{a = f /@ {.1, .2, .3, .4}},
Ordering[a, 1]]

{3}

If it has to be {{3}}:

Module[{a = f /@ {.1, .2, .3, .4}},
List@Ordering[a, 1]]

{{3}}

or just

List@Ordering[a = f /@ {.1, .2, .3, .4}, 1]

{{3}}

(No Module needed.)

Bobby

On Tue, 08 Mar 2011 04:36:06 -0600, Dwayne <dwaynedcole at gmail.com> wrote:

>
> This works:
>
> Position[A, Min[A]]]
>
> where, A = {5.3, 5.4, 5.2, 5.9}.  the Position function returns ( 3 ).
>
> But this doesn't
>
> Module[{ A, B, RETURN},
>              A = Table[ F, {i,{.1, .2, .3, .4}]; (* The function F
> returns {5.3, 5.4, 5.2, 5.9} *)
>              B = Position[A, Min[A]];
>             RETURN = B]
>
> The above module returns, { }.
>
> Is this a bug?
>
>
>

--
DrMajorBob at yahoo.com

```

• Prev by Date: Re: Please add me to this group
• Next by Date: Re: Please add me to this group
• Previous by thread: Re: Weird Position[list,form] behavior when used inside of Module.
• Next by thread: help with rotated graphic