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.
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.
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.
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
Last /@ {1 -> 3, 2 -> 4}– Alan Dec 05 '18 at 02:30FullForm@R. – Alan Dec 05 '18 at 03:07Imageas the name of a user-defined function, because it has built-in meanings. Second, what do you mean by a "relation"? Mathematica has no such a construct, I suppose. – Αλέξανδρος Ζεγγ Dec 05 '18 at 03:30R={1->2,3->4}; Values[R]? – xieyn Dec 05 '18 at 04:10