[Haskell-cafe] Newbie questions
Keith Wansbrough
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.
--KW 8-)
--
Keith Wansbrough <kw217 at cl.cam.ac.uk>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.
More information about the Haskell-Cafe
mailing list