Re: Sort within self-defined procedure
- To: mathgroup at smc.vnet.net
- Subject: [mg108593] Re: Sort within self-defined procedure
- From: dh <dh at metrohm.com>
- Date: Thu, 25 Mar 2010 04:21:47 -0500 (EST)
- References: <hocm9o$shi$1@smc.vnet.net>
Hi,
if you say:
ks[x_]= ..
then the right hand side is evaluated and the result (here {5,x,2,1})
assigned to ks. Hoever, what you want is delayed evaluation. This is
denoted by:
ks[x_]:= ..
Daniel
On 24.03.2010 10:33, dornakul wrote:
> Hi,
>
> I am desperate. Why is it not possible to sort a list within a self-
> defined procedure?
>
> Here comes the minimal example
>
> In[188]:= ks[x_] = Module[{l},
> l = {1, 5, x, 2};
> Sort[l, Greater]
> ]
>
> Out[188]= {5, x, 2, 1}
>
> In[190]:= ks[20]
>
> Out[190]= {5, 20, 2, 1}
>
> Dornakul
> Using Mathematica 7 on a Windows machine
>
--
Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>