Re: Converting a mapping into a well-defined function
- To: mathgroup at smc.vnet.net
- Subject: [mg56533] Re: [mg56499] Converting a mapping into a well-defined function
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Thu, 28 Apr 2005 02:40:28 -0400 (EDT)
- References: <200504270153.VAA01768@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Apr 26, 2005, at 9:53 PM, Gilmar wrote: > Dear Mathematica User Friends: > > I need to build a module that takes a non-empty set A > (whose elements are 2-tuples), and appends (or not) those 2-tuples > to a set B according to the following criteria: > > if A defines a mapping: > > A(a)=5, A(b)=27, A(a)=14, A(c)=4, A(e)=94, A(b)=6, A(d)=9, A(e)=4 > > them the module converts the mapping A into a well-defined function: > > A(a)=5, A(b)=27, A(c)=4, A(d)=9, A(e)=94. > > Thank you for your help You could try module[a_]:=First[First[#]]&/ @Split[Sort[Transpose[{a,Range[Length[a]]}],OrderedQ[{{#1[[1,1]],#1[[2]] },{#2[[1,1]],#2[[2]]}}]&],#1[[1,1]]==#2[[1,1]]&] Regards, Ssezi
- References:
- Converting a mapping into a well-defined function
- From: "Gilmar" <gilmar.rodriguez@nwfwmd.state.fl.us>
- Converting a mapping into a well-defined function