Suppose I have two Lists (Not equal length). Both contain random numbers between 0
to 5000
(or another max limit):
A= {1000, 450, 50, 4100, ...,670}
B={500, 10, 4561, 2000, ...}
I would like to take each number from List A
and compare it to all numbers in List B
.
If the absolute value of B
is smaller than A
I will count it. If not I will not count it.
For example, in the Lists above, we start with 1000
in List A and compare it to all numbers in B, 500<1000
, 10<1000
... I will count all numbers that are smaller than 1000
and Build a new List C
that contains integers which represents the amount of all numbers that were smaller than 1000
(here only 2
), 450
(only 1
), 50
(0
), 4100
(3
)...
In the next step I return the same procedure for 450
etc.
So C={2,1,0,3….}
Can someone help me and show me a way?
Map[Count[list2, x_ /; x < #] &, list1]
should get you started. If lists are huge, there are more efficient ways... $\endgroup$listC
fromlistA
andlistB
$\endgroup$