Re: Problems ....
- To: mathgroup@smc.vnet.net
- Subject: [mg11555] Re: [mg11532] Problems ....
- From: Des Penny <penny@suu.edu>
- Date: Sat, 14 Mar 1998 13:56:09 -0500
- Organization: Southern Utah University
- References: <199803131722.MAA03809@smc.vnet.net.>
Hi: The answers to your questions are as follows: Tie wrote: > I am a new user. need help to know more about mathematica. Anyone can > help me do the following: > > 1. Let Y={a,b} and let X be an arbitrary numeric vector. Replace all > occurances of a in X with b. In: x={1,3,-5,3,-4}; y={3,8}; x=x /. y[[1]]->y[[2]] Out: {1,8,-5,8,-4} > 2. Sort the elements of X in ascending order of absolute value. In:x={1,3,-5,3,-4}; x=Sort[x,Abs[#1]<Abs[#2]&] Out: {1,3,3,-4,-5} > > > 3. Square each elements of a vector X but keep its sign. In:x={1,3,-5,3,-4}; x=Map[Sign[#] #^2 &,x] Out: {1,9,-25,9,-16} > > > 4. Remove second element of the vector X without using the Table > function > In:x={1,3,-5,3,-4}; x=Drop[x,{2}] Out: {1,-5,3,-4} > thanks. Cheers, -- Des Penny Physical Science Dept. Southern Utah University Cedar City, UT 84720 Office: (435) 586-7708 FAX: (435) 865-8051 email: penny@suu.edu Home: (435) 586-2286 email: dpenny@iname.com
- References:
- Problems ....
- From: tie@cscn.com (Tie)
- Problems ....