MathGroup Archive 2006

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

Search the Archive

Re: Use pattern to find minimum without using min


First Sort the elements then pick up the first element of the list

lst = Table[Random[Integer, {3, 20}], {20}]
{14, 19, 8, 13, 18, 9, 6, 5, 13, 10, 12, 13, 11, 14, 12, 19, 16, 17,
14, 17}

lst //. {a___, b_, f___, c_, d___} /; c < b -> {a, c, d}
% /. {x_, y___} -> x

{5, 10, 11, 12, 14, 17}
5

Regards
Dimitris

Ï/Ç wooks Ýãñáøå:
> Tried
>
> {9, 4, 6, 5, 3, 7} //. {a___, b_, c___, d_, e___} :> b /; (b < d)
>
> and
>
> {9, 4, 6, 5, 3, 7} //. {x_,y_,z___} :> {x,z} /; (x<y)
> 
> without much success.


  • Prev by Date: Re: Use pattern to find minimum without using min
  • Next by Date: Re: Use pattern to find minimum without using min
  • Previous by thread: Re: Use pattern to find minimum without using min
  • Next by thread: Re: Use pattern to find minimum without using min