SlideShare a Scribd company logo
1 of 2
Download to read offline
i have a type mismatch error can you please help me fix this code
type Customer = {
Id: int
IsVip: bool
Credit: decimal
}
let getPurchases (customer: Customer) =
if customer.Id % 2 = 0 then
120.0M
else
80.0M
let tryPromoteToVip (customer: Customer) =
if getPurchases customer > 100.0M then
{ customer with IsVip = true }
else
customer
let increaseCreditIfVip (customer: Customer) =
if customer.IsVip then
{ customer with Credit = customer.Credit + 100.0M }
else
{ customer with Credit = customer.Credit + 50.0M }
let upgradeCustomerProcedural customer =
let purchases = getPurchases customer
let customer2 = tryPromoteToVip customer
increaseCreditIfVip customer2
let upgradeCustomerNested customer =
increaseCreditIfVip (tryPromoteToVip (customer |> getPurchases))
let upgradeCustomerComposed = getPurchases >> tryPromoteToVip >> increaseCreditIfVip
let upgradeCustomerPiped customer =
customer
|> tryPromoteToVip
|> increaseCreditIfVip
|> getPurchases
let customerVIP = { Id = 1; IsVip = true; Credit = 0.0M }
let customerSTD = { Id = 2; IsVip = false; Credit = 100.0M }
let assertVIP = upgradeCustomerComposed customerVIP = { Id = 1; IsVip = true; Credit = 100.0M
}
let assertSTDtoVIP = upgradeCustomerComposed customerSTD = { Id = 2; IsVip = true; Credit =
200.0M }
let assertSTD = upgradeCustomerComposed { customerSTD with Id = 3; Credit = 50.0M } = { Id =
3; IsVip = false; Credit = 100.0M }

More Related Content

More from sukhvir71

Hunger Games Catching Fire uso de medios digitales y socia.pdf
Hunger Games Catching Fire uso de medios digitales y socia.pdfHunger Games Catching Fire uso de medios digitales y socia.pdf
Hunger Games Catching Fire uso de medios digitales y socia.pdfsukhvir71
 
I need full assignment with every steps Write a program tha.pdf
I need full assignment  with every steps Write a program tha.pdfI need full assignment  with every steps Write a program tha.pdf
I need full assignment with every steps Write a program tha.pdfsukhvir71
 
I need an explanation for both the wrong and correct answers.pdf
I need an explanation for both the wrong and correct answers.pdfI need an explanation for both the wrong and correct answers.pdf
I need an explanation for both the wrong and correct answers.pdfsukhvir71
 
I need an explanation for the wrong and the correct answer .pdf
I need an explanation for the wrong and the correct answer  .pdfI need an explanation for the wrong and the correct answer  .pdf
I need an explanation for the wrong and the correct answer .pdfsukhvir71
 
I need help building a dictionary for the unique packets tha.pdf
I need help building a dictionary for the unique packets tha.pdfI need help building a dictionary for the unique packets tha.pdf
I need help building a dictionary for the unique packets tha.pdfsukhvir71
 
I need a help with a project I need to identify Grass lawn.pdf
I need a help with a project I need to identify Grass lawn.pdfI need a help with a project I need to identify Grass lawn.pdf
I need a help with a project I need to identify Grass lawn.pdfsukhvir71
 
I need an excel formula that will return 1 for HE17HE21 and.pdf
I need an excel formula that will return 1 for HE17HE21 and.pdfI need an excel formula that will return 1 for HE17HE21 and.pdf
I need an excel formula that will return 1 for HE17HE21 and.pdfsukhvir71
 
Hxxxp19x21 H5TNii5x21 c Why akould you espect th.pdf
Hxxxp19x21 H5TNii5x21 c Why akould you espect th.pdfHxxxp19x21 H5TNii5x21 c Why akould you espect th.pdf
Hxxxp19x21 H5TNii5x21 c Why akould you espect th.pdfsukhvir71
 
I measured the cooling rate X and surface hardness Y of .pdf
I measured the cooling rate X and surface hardness Y of .pdfI measured the cooling rate X and surface hardness Y of .pdf
I measured the cooling rate X and surface hardness Y of .pdfsukhvir71
 
I need a Full Runnable code and UML Diagram for the followin.pdf
I need a Full Runnable code and UML Diagram for the followin.pdfI need a Full Runnable code and UML Diagram for the followin.pdf
I need a Full Runnable code and UML Diagram for the followin.pdfsukhvir71
 
How would you explain the statement that CPR should not be .pdf
How would you explain the statement that CPR should not be .pdfHow would you explain the statement that CPR should not be .pdf
How would you explain the statement that CPR should not be .pdfsukhvir71
 
i Local supranational and governmental organisations amp.pdf
i Local supranational and governmental organisations amp.pdfi Local supranational and governmental organisations amp.pdf
i Local supranational and governmental organisations amp.pdfsukhvir71
 
I need finding assessmentresolutionmon Chief Complaint.pdf
I need  finding assessmentresolutionmon  Chief Complaint.pdfI need  finding assessmentresolutionmon  Chief Complaint.pdf
I need finding assessmentresolutionmon Chief Complaint.pdfsukhvir71
 
I have completed the nav bar and footer Im struggling with.pdf
I have completed the nav bar and footer Im struggling with.pdfI have completed the nav bar and footer Im struggling with.pdf
I have completed the nav bar and footer Im struggling with.pdfsukhvir71
 
i How does Pauly view the need for public insurance or just.pdf
i How does Pauly view the need for public insurance or just.pdfi How does Pauly view the need for public insurance or just.pdf
i How does Pauly view the need for public insurance or just.pdfsukhvir71
 
I have this python code and i am trying to Build a multivari.pdf
I have this python code and i am trying to Build a multivari.pdfI have this python code and i am trying to Build a multivari.pdf
I have this python code and i am trying to Build a multivari.pdfsukhvir71
 
hygiene and ecology theme 5 answer all questions from 1 to .pdf
hygiene and ecology theme 5  answer all questions from 1 to .pdfhygiene and ecology theme 5  answer all questions from 1 to .pdf
hygiene and ecology theme 5 answer all questions from 1 to .pdfsukhvir71
 
I How will u appl these steps to tackle vaccinatain sketic.pdf
I How will u appl these steps to tackle vaccinatain sketic.pdfI How will u appl these steps to tackle vaccinatain sketic.pdf
I How will u appl these steps to tackle vaccinatain sketic.pdfsukhvir71
 
i Ipts Compute the weakest precondition for the following.pdf
i Ipts Compute the weakest precondition for the following.pdfi Ipts Compute the weakest precondition for the following.pdf
i Ipts Compute the weakest precondition for the following.pdfsukhvir71
 
I have to make this program ask a user how many times my nam.pdf
I have to make this program ask a user how many times my nam.pdfI have to make this program ask a user how many times my nam.pdf
I have to make this program ask a user how many times my nam.pdfsukhvir71
 

More from sukhvir71 (20)

Hunger Games Catching Fire uso de medios digitales y socia.pdf
Hunger Games Catching Fire uso de medios digitales y socia.pdfHunger Games Catching Fire uso de medios digitales y socia.pdf
Hunger Games Catching Fire uso de medios digitales y socia.pdf
 
I need full assignment with every steps Write a program tha.pdf
I need full assignment  with every steps Write a program tha.pdfI need full assignment  with every steps Write a program tha.pdf
I need full assignment with every steps Write a program tha.pdf
 
I need an explanation for both the wrong and correct answers.pdf
I need an explanation for both the wrong and correct answers.pdfI need an explanation for both the wrong and correct answers.pdf
I need an explanation for both the wrong and correct answers.pdf
 
I need an explanation for the wrong and the correct answer .pdf
I need an explanation for the wrong and the correct answer  .pdfI need an explanation for the wrong and the correct answer  .pdf
I need an explanation for the wrong and the correct answer .pdf
 
I need help building a dictionary for the unique packets tha.pdf
I need help building a dictionary for the unique packets tha.pdfI need help building a dictionary for the unique packets tha.pdf
I need help building a dictionary for the unique packets tha.pdf
 
I need a help with a project I need to identify Grass lawn.pdf
I need a help with a project I need to identify Grass lawn.pdfI need a help with a project I need to identify Grass lawn.pdf
I need a help with a project I need to identify Grass lawn.pdf
 
I need an excel formula that will return 1 for HE17HE21 and.pdf
I need an excel formula that will return 1 for HE17HE21 and.pdfI need an excel formula that will return 1 for HE17HE21 and.pdf
I need an excel formula that will return 1 for HE17HE21 and.pdf
 
Hxxxp19x21 H5TNii5x21 c Why akould you espect th.pdf
Hxxxp19x21 H5TNii5x21 c Why akould you espect th.pdfHxxxp19x21 H5TNii5x21 c Why akould you espect th.pdf
Hxxxp19x21 H5TNii5x21 c Why akould you espect th.pdf
 
I measured the cooling rate X and surface hardness Y of .pdf
I measured the cooling rate X and surface hardness Y of .pdfI measured the cooling rate X and surface hardness Y of .pdf
I measured the cooling rate X and surface hardness Y of .pdf
 
I need a Full Runnable code and UML Diagram for the followin.pdf
I need a Full Runnable code and UML Diagram for the followin.pdfI need a Full Runnable code and UML Diagram for the followin.pdf
I need a Full Runnable code and UML Diagram for the followin.pdf
 
How would you explain the statement that CPR should not be .pdf
How would you explain the statement that CPR should not be .pdfHow would you explain the statement that CPR should not be .pdf
How would you explain the statement that CPR should not be .pdf
 
i Local supranational and governmental organisations amp.pdf
i Local supranational and governmental organisations amp.pdfi Local supranational and governmental organisations amp.pdf
i Local supranational and governmental organisations amp.pdf
 
I need finding assessmentresolutionmon Chief Complaint.pdf
I need  finding assessmentresolutionmon  Chief Complaint.pdfI need  finding assessmentresolutionmon  Chief Complaint.pdf
I need finding assessmentresolutionmon Chief Complaint.pdf
 
I have completed the nav bar and footer Im struggling with.pdf
I have completed the nav bar and footer Im struggling with.pdfI have completed the nav bar and footer Im struggling with.pdf
I have completed the nav bar and footer Im struggling with.pdf
 
i How does Pauly view the need for public insurance or just.pdf
i How does Pauly view the need for public insurance or just.pdfi How does Pauly view the need for public insurance or just.pdf
i How does Pauly view the need for public insurance or just.pdf
 
I have this python code and i am trying to Build a multivari.pdf
I have this python code and i am trying to Build a multivari.pdfI have this python code and i am trying to Build a multivari.pdf
I have this python code and i am trying to Build a multivari.pdf
 
hygiene and ecology theme 5 answer all questions from 1 to .pdf
hygiene and ecology theme 5  answer all questions from 1 to .pdfhygiene and ecology theme 5  answer all questions from 1 to .pdf
hygiene and ecology theme 5 answer all questions from 1 to .pdf
 
I How will u appl these steps to tackle vaccinatain sketic.pdf
I How will u appl these steps to tackle vaccinatain sketic.pdfI How will u appl these steps to tackle vaccinatain sketic.pdf
I How will u appl these steps to tackle vaccinatain sketic.pdf
 
i Ipts Compute the weakest precondition for the following.pdf
i Ipts Compute the weakest precondition for the following.pdfi Ipts Compute the weakest precondition for the following.pdf
i Ipts Compute the weakest precondition for the following.pdf
 
I have to make this program ask a user how many times my nam.pdf
I have to make this program ask a user how many times my nam.pdfI have to make this program ask a user how many times my nam.pdf
I have to make this program ask a user how many times my nam.pdf
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Fix Type Mismatch Error in F# Code

  • 1. i have a type mismatch error can you please help me fix this code type Customer = { Id: int IsVip: bool Credit: decimal } let getPurchases (customer: Customer) = if customer.Id % 2 = 0 then 120.0M else 80.0M let tryPromoteToVip (customer: Customer) = if getPurchases customer > 100.0M then { customer with IsVip = true } else customer let increaseCreditIfVip (customer: Customer) = if customer.IsVip then { customer with Credit = customer.Credit + 100.0M } else { customer with Credit = customer.Credit + 50.0M } let upgradeCustomerProcedural customer = let purchases = getPurchases customer let customer2 = tryPromoteToVip customer increaseCreditIfVip customer2 let upgradeCustomerNested customer = increaseCreditIfVip (tryPromoteToVip (customer |> getPurchases)) let upgradeCustomerComposed = getPurchases >> tryPromoteToVip >> increaseCreditIfVip let upgradeCustomerPiped customer = customer |> tryPromoteToVip |> increaseCreditIfVip |> getPurchases let customerVIP = { Id = 1; IsVip = true; Credit = 0.0M } let customerSTD = { Id = 2; IsVip = false; Credit = 100.0M } let assertVIP = upgradeCustomerComposed customerVIP = { Id = 1; IsVip = true; Credit = 100.0M } let assertSTDtoVIP = upgradeCustomerComposed customerSTD = { Id = 2; IsVip = true; Credit =
  • 2. 200.0M } let assertSTD = upgradeCustomerComposed { customerSTD with Id = 3; Credit = 50.0M } = { Id = 3; IsVip = false; Credit = 100.0M }