New to sml, I'm trying to find out how to write multiple if statements without them being nested. for example if im trying to find the median, I want:
if(a > b && b > c){return b;}
else if (b > a && a > c) {return a;}
else if (a > c && c > a) {return c;}
and so on and so forth
i tried this:
fun median(a,b,c) =
if a > b andalso b > c then b
else if b > a andalso a > c then a
else if a > c andalso c > b then c
however it treats it as if they are all nested within one another. how would i make each if statement seperate
Aucun commentaire:
Enregistrer un commentaire