Minor fix
This commit is contained in:
parent
02a760984d
commit
b5b29e99d6
|
@ -16,34 +16,44 @@ var $$Math = {
|
||||||
divide: divide
|
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 = company.currentPrice;
|
||||||
|
var match$1 = company.marketCap;
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case /* SHARE_PRICE */0 :
|
case /* SHARE_PRICE */0 :
|
||||||
if (match !== undefined && year > 2019 && year < 2030) {
|
if (match !== undefined && year > 2019 && year < 2030) {
|
||||||
var diffYears = year - 2020 | 0;
|
var diffYears = year - otherSettings.currentYear | 0;
|
||||||
return normal(match, diffYears * 0.1);
|
return normal(match, diffYears * 0.1);
|
||||||
} else {
|
} else {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
case /* SHARES_OUTSTANDING */1 :
|
case /* SHARES_OUTSTANDING */1 :
|
||||||
if (year > 2019 && year < 2030) {
|
if (year > 2019 && year < 2030) {
|
||||||
var price = run(company, year, /* SHARE_PRICE */0);
|
var price = run(company, year, /* SHARE_PRICE */0, otherSettings);
|
||||||
var marketCap = run(company, year, /* MARKET_CAP */2);
|
var marketCap = run(company, year, /* MARKET_CAP */2, otherSettings);
|
||||||
if (price !== undefined && marketCap !== undefined) {
|
return sharesOutstanding(price, marketCap);
|
||||||
return divide(marketCap, price);
|
|
||||||
} else {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
case /* MARKET_CAP */2 :
|
case /* MARKET_CAP */2 :
|
||||||
|
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 ;
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.$$Math = $$Math;
|
exports.$$Math = $$Math;
|
||||||
|
exports.sharesOutstanding = sharesOutstanding;
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
/* No side effect */
|
/* No side effect */
|
||||||
|
|
42
src/Test2.re
42
src/Test2.re
|
@ -19,25 +19,37 @@ type param =
|
||||||
type company = {
|
type company = {
|
||||||
name: string,
|
name: string,
|
||||||
currentPrice: option(float),
|
currentPrice: option(float),
|
||||||
|
marketCap: option(float),
|
||||||
};
|
};
|
||||||
|
|
||||||
let rec run = (company: company, year: int, param: param) => {
|
type otherSettings = {currentYear: int};
|
||||||
switch (param, year, company.currentPrice) {
|
|
||||||
| (SHARE_PRICE, year, Some(price)) when year > 2019 && year < 2030 =>
|
let sharesOutstanding = (price, marketCap) =>
|
||||||
let diffYears = year - 2020;
|
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;
|
let diffPerYear = 0.1;
|
||||||
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
|
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
|
||||||
|
| (MARKET_CAP, year, _, Some(price)) when year > 2019 && year < 2030 =>
|
||||||
| (SHARES_OUTSTANDING, year, _) when year > 2019 && year < 2030 =>
|
let diffYears = year - otherSettings.currentYear;
|
||||||
let price = run(company, year, SHARE_PRICE);
|
let diffPerYear = 0.1;
|
||||||
let marketCap = run(company, year, MARKET_CAP);
|
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
|
||||||
switch (price, marketCap) {
|
| (SHARES_OUTSTANDING, year, _, _) when year > 2019 && year < 2030 =>
|
||||||
| (Some(price), Some(marketCap)) =>
|
let price = run(company, year, SHARE_PRICE, otherSettings);
|
||||||
Some(Math.divide(marketCap, price))
|
let marketCap = run(company, year, MARKET_CAP, otherSettings);
|
||||||
|
sharesOutstanding(price, marketCap);
|
||||||
| _ => None
|
|
||||||
};
|
|
||||||
|
|
||||||
| _ => None
|
| _ => None
|
||||||
};
|
};
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user