jeudi 8 janvier 2015

What is idiomatic way in f# to express sequence of if statements with overlapping conditions


Let's say I got code like this:



if(conditionA)
do something
if(conditionA && conditionB)
do something more


Obviously, I could nest the ifs (although when there are more complicated conditions this is not readable for me) like below:



if(conditionA)
do something
if(conditionB)
do something more


How can I write similar code in f# idiomatically. I assume if statement isn't considered idiomatic in functional programming (am I wrong?)


I could write two subsequent match expressions or nested match expression to mimic above code but doing so seems pretty ugly to me.





Aucun commentaire:

Enregistrer un commentaire