Skip to content

Instantly share code, notes, and snippets.

@kowasaur
Created November 5, 2021 08:10
Show Gist options
  • Save kowasaur/7c214080193936a241c3cda56cb335a1 to your computer and use it in GitHub Desktop.
Save kowasaur/7c214080193936a241c3cda56cb335a1 to your computer and use it in GitHub Desktop.
Thing I made for my specialist maths homework
-- Used to solve specialist homework question
-- Constants
breedingRates = [ 0, 1.3, 1.8, 0.9, 0.2]
survivalRates = [0.6, 0.8, 0.8, 0.4, 0]
initialPopulations = [194, 82, 55, 22, 6]
-- Population after n years
populations 0 = initialPopulations
-- The takeWhile is unnecessary but I added it in case the last survival rate isn't 0
populations n = takeWhile (>0) $ sum (zipWith (*) (populations (n-1)) breedingRates) : zipWith (*) (populations (n-1)) survivalRates
wholePopulations n = map floor $ populations n
totalPopulation n = sum $ populations n
totalWholePopulation n = floor $ totalPopulation n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment