It sounds like you have an array J and you want to map each element of J to 
a unique integer in 1:N for N as small as possible?  This will do it:

d = (Int=>eltype(J))[j => i for (i,j) in enumerate(unique(J))]

Jcodes = [d[j] for j in J]

 Here, d is a dictionary mapping integers in 1:N to the corresponding 
values in J, and Jcodes is the "re-coded" array.

Reply via email to