To solve his specific question: in mathematics, if it takes no arguments and returns a random string of length n, it probably is not a function at all! That is, if f () is not equal to f () (for example, with f () = rand ()), then by definition f () is not a function. You can solve this in different ways, depending on your preferences: you can pass a status parameter to it and return the changed status parameter to it, or you can make it a multi-valued function and return all possible values, or you could use two functions: f ( n, state) gives the next random string of length n, and g (n, state) gives a new state after generating f (n, state).
source share