[Haskell-cafe] Stack Space Overflow.

Stefan O'Rear stefanor at cox.net
Sun Mar 18 17:22:34 EDT 2007


On Sun, Mar 18, 2007 at 04:20:31PM -0500, John T Davis wrote:
> oHello,
> 
> I'm writing a simulation of a game of Nim with genetic programming.  
> I've run into a stack space overflow problem with one of my functions  
> (part of a class instance), which I've included below.
> 
> crossover_mutate enp = enp { progPop  = ansPop,
>                                  numProgs = (numProgs enp) +  
> (crossNum enp)}
> 
>         where
>         crossResult  = crossNimPlayerPop (progPop enp) (seed enp)  
> (theBoard enp) (numProgs enp) (crossNum enp)
>         mutateResult = mutateNimPlayerPop crossResult (mutateRatio enp)
>         popParts = crossResult ++ mutateResult
>         newPop   = Set.toAscList (Set.fromList popParts)
> 
>         ansPop   = tournament (newPop, newPop) (theBoard enp)
> 
> Now, here's where it gets weird.  I've got test data that I've run  
> all the constituent functions (crossNimPlayerPop, mutateNimPlayerPop,  
> tournament) on, and they all work as they should.  Now, when I run  
> the same data on crossover_mutate, I get the aforementioned stack  
> space overflow.  I'm totally stumped on this...  I've even run the  
> equivalent of ansPop on the command line, and despite how truly  
> unreadable the code is in that format, it runs fine.
> 
> Any suggestions or thoughts would be greatly appreciated.  Have a  
> nice day.  :-)

This was solved on #haskell yesterday after you left.

http://tunes.org/~nef/logs/haskell/07.03.17

Scroll down to 21:48:47 and read stepcut's comment.

Stefan


More information about the Haskell-Cafe mailing list