Minor fix

This commit is contained in:
Ozzie Gooen 2020-02-05 22:14:59 +00:00
parent 02a760984d
commit b5b29e99d6
2 changed files with 47 additions and 25 deletions

View File

@ -16,34 +16,44 @@ var $$Math = {
divide: divide
};
function run(company, year, param) {
function sharesOutstanding(price, marketCap) {
if (price !== undefined && marketCap !== undefined) {
return divide(marketCap, price);
}
}
function run(company, year, param, otherSettings) {
var match = company.currentPrice;
var match$1 = company.marketCap;
switch (param) {
case /* SHARE_PRICE */0 :
if (match !== undefined && year > 2019 && year < 2030) {
var diffYears = year - 2020 | 0;
var diffYears = year - otherSettings.currentYear | 0;
return normal(match, diffYears * 0.1);
} else {
return ;
}
case /* SHARES_OUTSTANDING */1 :
if (year > 2019 && year < 2030) {
var price = run(company, year, /* SHARE_PRICE */0);
var marketCap = run(company, year, /* MARKET_CAP */2);
if (price !== undefined && marketCap !== undefined) {
return divide(marketCap, price);
} else {
return ;
}
var price = run(company, year, /* SHARE_PRICE */0, otherSettings);
var marketCap = run(company, year, /* MARKET_CAP */2, otherSettings);
return sharesOutstanding(price, marketCap);
} else {
return ;
}
case /* MARKET_CAP */2 :
return ;
if (match$1 !== undefined && year > 2019 && year < 2030) {
var diffYears$1 = year - otherSettings.currentYear | 0;
return normal(match$1, diffYears$1 * 0.1);
} else {
return ;
}
}
}
exports.$$Math = $$Math;
exports.sharesOutstanding = sharesOutstanding;
exports.run = run;
/* No side effect */

View File

@ -19,25 +19,37 @@ type param =
type company = {
name: string,
currentPrice: option(float),
marketCap: option(float),
};
let rec run = (company: company, year: int, param: param) => {
switch (param, year, company.currentPrice) {
| (SHARE_PRICE, year, Some(price)) when year > 2019 && year < 2030 =>
let diffYears = year - 2020;
type otherSettings = {currentYear: int};
let sharesOutstanding = (price, marketCap) =>
switch (price, marketCap) {
| (Some(price), Some(marketCap)) => Some(Math.divide(marketCap, price))
| _ => None
};
let rec run =
(
company: company,
year: int,
param: param,
otherSettings: otherSettings,
) => {
switch (param, year, company.currentPrice, company.marketCap) {
| (SHARE_PRICE, year, Some(price), _) when year > 2019 && year < 2030 =>
let diffYears = year - otherSettings.currentYear;
let diffPerYear = 0.1;
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
| (SHARES_OUTSTANDING, year, _) when year > 2019 && year < 2030 =>
let price = run(company, year, SHARE_PRICE);
let marketCap = run(company, year, MARKET_CAP);
switch (price, marketCap) {
| (Some(price), Some(marketCap)) =>
Some(Math.divide(marketCap, price))
| _ => None
};
| (MARKET_CAP, year, _, Some(price)) when year > 2019 && year < 2030 =>
let diffYears = year - otherSettings.currentYear;
let diffPerYear = 0.1;
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
| (SHARES_OUTSTANDING, year, _, _) when year > 2019 && year < 2030 =>
let price = run(company, year, SHARE_PRICE, otherSettings);
let marketCap = run(company, year, MARKET_CAP, otherSettings);
sharesOutstanding(price, marketCap);
| _ => None
};
};