1
$\begingroup$

I have 2 rules:

Rule[#, SomeFunction[#]] &/@ SomeFunctionArgs;
Rule[#, OtherFunction[#]] &/@ OtherFunctionArgs;

I want to have one function that combines the 2 results in 1. I have tried to do:

MainFunction[] =: ( Rule[#, SomeFunction[#]] &/@ SomeFunctionArgs; Rule[#, OtherFunction[#]] &/@ OtherFunctionArgs)

But this didn't work.

Any advices?

UPDADE:

SomeFunctionArgs = {
    "A",
    "B"
}

OtherFunctionArgs = { 
    "C",
    "D"
}

This will give {A -> "result1", B -> "result2"}

Rule[#, SomeFunction[#]] &/@ SomeFunctionArgs

This will give {C -> "result3", D -> "result4"}

Rule[#, OtherFunction[#]] &/@ OtherFunctionArgs

I want MainFunction[] to give the following result:

{A -> "result1", B -> "result2", C -> "result3", D -> "result4"}

$\endgroup$

closed as off-topic by Mike Honeychurch, Oleksandr R., Michael E2, Yves Klett, Artes Jan 18 '15 at 15:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Mike Honeychurch, Oleksandr R., Michael E2, Yves Klett, Artes
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Why not simply use Join? $\endgroup$ – DavidC Jan 17 '15 at 13:59
  • $\begingroup$ Are you just seeking to apply a function to specific set of arguments as you would using the Map[] function ? Or is your goal something different ? Perhaps some input and output examples might make this more evident. $\endgroup$ – image_doctor Jan 17 '15 at 14:01
  • $\begingroup$ Please see the update $\endgroup$ – SuTron Jan 17 '15 at 14:10
1
$\begingroup$

I figured it out.

Join[
Rule[#, SomeFunction[#]] &/@ SomeFunctionArgs,
Rule[#, OtherFunction[#]] &/@ OtherFunctionArgs
]

This does the required. I was failing, as I was using ; instead of ,.

@ David Carraher Thanks for the comment.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.