mercredi 27 août 2014

Passing function as argument in F#


Vote count:

0




In the following example, I'm receiving the error "No overloads match for method 'op_Subtraction'."



open System

type EmployeeStatus =
| Active
| NotActive

type EnrollmentPeriod =
| JanuaryFirst
| JulyFirst
| PeriodNotApplicable

let DetermineTargettedEnrollmentDate targettedEnrollmentDate (relativeDate : DateTime) =
match targettedEnrollmentDate with
| EnrollmentPeriod.JanuaryFirst -> new DateTime(relativeDate.Year + 1,1,1)
| EnrollmentPeriod.JulyFirst -> new DateTime(relativeDate.Year,7,1)
| EnrollmentPeriod.PeriodNotApplicable -> relativeDate

let ProjectDaysWorkedSinceJan1 employeeStatus targettedEnrollmentPeriod (relativeDate : DateTime) =
let januaryFirst = DateTime(relativeDate.Year,1,1)
let targettedEnrollmentDate = DetermineTargettedEnrollmentDate targettedEnrollmentPeriod
match employeeStatus with
| Active -> int (januaryFirst - targettedEnrollmentDate).TotalDays
| NotActive -> 0


It doesn't appear to like that targettedEnrollmentDate is being determined by the DetermineTargettedEnrollmentDate function.


Where am I going wrong here?



asked 1 min ago

Joe

24






Passing function as argument in F#

Aucun commentaire:

Enregistrer un commentaire