Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Trace[ Through [ (Max - Min) [ {1, 2, 3, 4, 5} ] ] ]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58751] Trace[ Through [ (Max - Min) [ {1, 2, 3, 4, 5} ] ] ]
  • From: Zhe Hu <iamhuzhe at gmail.com>
  • Date: Sun, 17 Jul 2005 03:04:02 -0400 (EDT)
  • Reply-to: Zhe Hu <iamhuzhe at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

I tried to get the difference between the largest and the smallest
elements in a list.

Max[mylist] - Min[mylist]  OR (Max[#]-Min[#])&[mylist]  would get the job done.

However just to be fancy, I tried

Through[Max - Min, mylist] .

It didn't work as expected. Try

Trace[ Through [ (Max - Min) [ {1, 2, 3, 4, 5} ] ] ]

I guess the problem is "Max - Min" was turned into "Max + (-Min)" and
"(-Min)" won't be applied correctly.

One way to go around this problem is to try

Subtract@@Through[{Max, Min}[{1, 2, 3, 4, 5}]]

But that's kind of ugly. Is there better solutions? Thanks.

Sincerely,
Hu Zhe

P.S.
In a language called "J". This is termed "fork". Their expression would be:
(>./ - <./) 1 2 3 4 5


  • Prev by Date: Eliminating Annoying Minus Signs
  • Next by Date: Re: refining expression in terms of real numbers
  • Previous by thread: Re: Re: Eliminating Annoying Minus Signs
  • Next by thread: Re: Trace[ Through [ (Max - Min) [ {1, 2, 3, 4, 5} ] ] ]