mercredi 20 janvier 2016

I think this would be pattern matching not sure

I just want to say "usd_to_euro 100" and get back the correct amount of euros (ex: 90) for my particular day. What does create_exchange_functions need to return?

let create_exchange_functions (usd_to_euro_rate, usd_to_yuan_rate, usd_to_peso_rate, usd_to_pound_rate, usd_to_ruble_rate) = 
    (??, ??, ??, ....??);

//on the morning of day x I run this:

let (usd_to_euro, usd_to_yuan, usd_to_peso, usd_to_pound, usd_to_ruble) = create_exchange_functions(0.9, 4., 3., 0.6, 5.);
usd_to_pound 10.;

//on the morning of day y I run this:

let (usd_to_euro, usd_to_yuan, usd_to_peso, usd_to_pound, usd_to_ruble) = create_exchange_functions(0.92, 3.8, 3., 0.65, 5.);
usd_to_pound 10.;

//on the morning of day z I run this:

let (usd_to_euro, usd_to_yuan, usd_to_peso, usd_to_pound, usd_to_ruble) = create_exchange_functions(0.92, 3.8, 3., 0.62, 5.);
usd_to_pound 10.;

Aucun commentaire:

Enregistrer un commentaire