Hi everyone . I want to make an array inside a struct and randomly generate initial states.
Random function
3 posts · 4189 views
Re: Random function
Too vague for me. What dialect are you implementing this in and what have you tried so far?
A general hunch is that you need to create the array then traverse it using a random function to give each slot a value. The fact that the array is in a struct is not very relevant.
A general hunch is that you need to create the array then traverse it using a random function to give each slot a value. The fact that the array is in a struct is not very relevant.
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p
Currently I'm planning a Scheme compiler :p
Re: Random function
If you are using defstruct, you will need to create a separate function to initialize the contents. If you are using defclass, then you can use "(defmethod initialize-instance :after" to do the initialization.