[Haskell-cafe] Newbie questions
Keith.Wansbrough at cl.cam.ac.uk
Fri Jul 2 06:07:23 EDT 2004
> -- gaSolutionSpace :: [a] -> [a]
> -- gaSolutionSpace  = gaSolutionSpace createRandomPopulation -- recursive
> base case
> gaSolutionSpace x = x : gaSolutionSpace (evolvepopulation x)
This isn't quite right - you don't want the *last* element to be the initial population, but the first.
I think you mean:
gaSolutionSpaceFrom :: a -> [a]
gaSolutionSpaceFrom x = x : gaSolutionSpaceFrom (evolvepopulation x)
gaSolutionSpace = gaSolutionSpaceFrom createRandomPopulation
Note that "a" above should be replaced with your population type.
Also note the "iterate" function in the standard library does just this.
Keith Wansbrough <kw217 at cl.cam.ac.uk>
University of Cambridge Computer Laboratory.
More information about the Haskell-Cafe