Random function

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
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.

Random function

Postby Ehsan » Sun Aug 26, 2012 12:42 am

Hi everyone . I want to make an array inside a struct and randomly generate initial states.
Ehsan
 
Posts: 8
Joined: Thu Jul 12, 2012 7:39 am

Re: Random function

Postby sylwester » Mon Aug 27, 2012 6:20 am

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.
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p
sylwester
 
Posts: 83
Joined: Mon Jul 11, 2011 2:53 pm

Re: Random function

Postby nuntius » Mon Aug 27, 2012 4:37 pm

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.
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Homework

Who is online

Users browsing this forum: No registered users and 1 guest