0

How I can get only the second part of this relation? I want to get Image of function where R is a relation and A is a set.

Image[R_, A_] := Block[{}, For[i = 0, i < Length[A], i++, Select[#2[R]]]]

But it doesn't work.

BlueMan
  • 1
  • 1

1 Answers1

3

Due to the policy of this forum I cannot add comments, so I type here.

In order to get from R={1->2,3->4} 2 and 4 you can always use R[[;;,2]]. I do not know how helpful it is for your main problem, which I do not understand correctly, maybe.

If A is a set (a List?), e.g., {1,2,3}, and R is a set of rules, e.g., {1->2,2->3,3->4}, you could use A/.R to get the ''Image'' {2,3,4}. Is that what you are looking for?

If not, please be a bit more specific about what is your input and wished output.

Henrik Schumacher
  • 106,770
  • 7
  • 179
  • 309
MK.
  • 341
  • 2
  • 7
  • I should write Block[{},Print[A/.R]]? – BlueMan Dec 05 '18 at 11:52
  • It depends on what you would like to do with the result. If you just want to print it out on the screen, then it will do the job. Actually, it would do the job without the Block construction. However, if you would like to further process it, e.g., apply another mapping to obtain yet another image, you could go for something like img1 = A/.R1, and then you could print it with Print[img1], but also further process it with, e.g., img2 = img1/.R2, and so on. If you prefer to have a function for that you can simply try image[A_,R_] := A/.R. As I mentioned, it depends on your precise goals – MK. Dec 05 '18 at 13:59