I have a Table which includes {Numbers, Probabilities}
.
For example A= {{1,0.5},{2,0.25}, {3,0.1},{4,0.9}……{100,0.1}}
. Put attention that the numbers are 1,2….100 in order.
I have a List of random numbers (same length like the Table and can include duplicates).
For example B={2,5,100,500, 61,250,8……19}
.
I would like to build an short algorithm that will :
(1) Choose each number in List B and check if its appear in Table A,
(2) If it's there, for example "2" it will be a term in a new Table C which includes again {Number, Probability from Table A) = {2,0.25} . Here we build a new Table C.
(3) If the number in List B does not appears in A than Null (nothing).
I will be thankful to get a solution.
A
andB
have 100 elements, but listC
will have a length some number less than 100? $\endgroup$Null
- do you mean nothing, no element there, in which listC
will be smaller than listsA
and listsB
, or do you specifically want to have the wordNull
in those positions? From your answer above I assume you want the first, but others have interpreted your question as it was written $\endgroup$