Random function
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Random function
Hi everyone . I want to make an array inside a struct and randomly generate initial states.
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.