MathGroup Archive 2005

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

Search the Archive

Re: Converting a mapping into a well-defined function


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


  • Prev by Date: Re: NIntegrate and NDSolve
  • Next by Date: Re: Polar Plots don't seem to work
  • Previous by thread: Converting a mapping into a well-defined function
  • Next by thread: Re: Converting a mapping into a well-defined function