0 people like it.

CostStudy.fsx

Simple Cost Study

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
[<Measure>] type eur;       //defino la dimension dinero
[<Measure>] type month;     //defino el tiempo en meses
[<Measure>] type day;       //defino tiempo en dias
[<Measure>]
type hour = 
  static member workDay = 8.0<hour/day>;    //defino el tiempo en horas y la conversion por dia laborable
[<Measure>] 
type min = 
  static member perHour = 60.0<min hour^-1>;    //defino el tiempo en minutos y la conversion a horas

let hourRate = 60.0<eur/hour>;      //defino la tarifa horaria

let avgMonthlyEffort = 20.0<day/month> * hour.workDay //cuantas horas de esfuerzo tiene un mes con 20 dias laborables?
let avgMonthlyCost = avgMonthlyEffort * hourRate //cuanto cuesta segun la tarifa?

let monthCost = 8000.0<eur/month> //defino que un mes me ha costado 8000 euros
let hourCost = monthCost / 20.0<day/month> / hour.workDay //¿que tarifa me han aplicado?
Multiple items
type MeasureAttribute =
  inherit Attribute
  new : unit -> MeasureAttribute

Full name: Microsoft.FSharp.Core.MeasureAttribute

--------------------
new : unit -> MeasureAttribute
[<Measure>]
type eur

Full name: Script.eur
[<Measure>]
type month

Full name: Script.month
[<Measure>]
type day

Full name: Script.day
[<Measure>]
type hour =
  static member workDay : float<hour/day>

Full name: Script.hour
static member hour.workDay : float<hour/day>

Full name: Script.hour.workDay
[<Measure>]
type min =
  static member perHour : float<min/hour>

Full name: Script.min
static member min.perHour : float<min/hour>

Full name: Script.min.perHour
val hourRate : float<eur/hour>

Full name: Script.hourRate
val avgMonthlyEffort : float<hour/month>

Full name: Script.avgMonthlyEffort
property hour.workDay: float<hour/day>
val avgMonthlyCost : float<eur/month>

Full name: Script.avgMonthlyCost
val monthCost : float<eur/month>

Full name: Script.monthCost
val hourCost : float<eur/hour>

Full name: Script.hourCost
Raw view New version

More information

Link:http://fssnip.net/nq
Posted:2 years ago
Author:NicolasDobler
Tags: t4pl , tryfsharp