reset password
Author Message
alishas15
Posts: 10
Posted 12:49 Oct 11, 2015 |

So I'm not really sure what I'm doing wrong but when I enter (history) after playing a game or two my program kind of crashes and doesn't print anything out. My (history) function is:

(define (history)
  (display (reverse gamesPlayed)))

and I have this in (correct):

 (set! gamesPlayed (append (list (theGame numOfGames startLower startUpper finalLower finalUpper secretNum stored)) gamesPlayed)))

When I have not played any games and I type in (history) it prints out an empty list because I set gamesPlayed to be the empty list.

 

 

Aperez78
Posts: 4
Posted 12:52 Oct 11, 2015 |

I would try using cons, it was much more easier to understand.
but check if your getting the data first, print out your local variables it might be that no data is being sent

rabbott
Posts: 1649
Posted 12:57 Oct 11, 2015 |

I agree. Use cons instead of creating a list and then using append. It's simpler and more straightforward.

I would also be sure your custom write function is working properly. Create a game at the prompt and see if it prints as you expect.

alishas15
Posts: 10
Posted 14:02 Oct 11, 2015 |

Thank you for the feedback. I will try cons procedure after I figure out my custom-write. After reading Dr. Abbott's comment I went back to try it out and I realized it's doing the same kind of crashing. 

Update: I've figured it out. Thank you.

Last edited by alishas15 at 15:27 Oct 11, 2015.