SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler 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 }

Mais conteúdo relacionado

Mais de sukhvir71

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
sukhvir71
 
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
sukhvir71
 
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
sukhvir71
 
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
sukhvir71
 
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
sukhvir71
 
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
sukhvir71
 

Mais de 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
 

Último

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Último (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
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 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
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
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
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"
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

i have a type mismatch error can you please help me fix this.pdf

  • 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 }