I have a set of functions and I would like each one to return a different prime number. I don’t care which function returns which prime, but they must all be distinct.
What I’d like to be able to do is write something like:
return #uniquePrime#;
And then have all of these converted to actual numbers when I compile the code.
Is this possible? Or something with a similar effect? (other than hard-coding a set of prime numbers)
Thanks!
Although I don’t understand why you want to do this. You could create a
method
nextPrime("methodName")which creates a prime number and registers it in aHashMap<String,Integer>where String is the method name received as argument and Integer stores the prime. If the method is called again you can lookup whether the prime number was already calculated and return it. You can check the HashMap to see if a prime number was already used for another method.Instead of
return #uniquePrime#;you would
return nextPrime("methodName");