Page 1 of 1

Random function

PostPosted: Sun Aug 26, 2012 12:42 am
by Ehsan
Hi everyone . I want to make an array inside a struct and randomly generate initial states.

Re: Random function

PostPosted: Mon Aug 27, 2012 6:20 am
by sylwester
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.

Re: Random function

PostPosted: Mon Aug 27, 2012 4:37 pm
by nuntius
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.