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