sml - Wildcards in Standard ML -
i came across following function in ml working programmer:
fun null [] = true | null (_::_) = false
1) can't both wildcards empty lists? if not, how ml prevent this?
2) function shortened be:
fun null [] = true | false
why / why not?
thanks help, bclayman
yes, can, matched list won't empty, result of
null
function holds, i.e.,[] :: []
, equivalent[[]]
, not empty list.no, that's syntactically invalid. however, can shortened this:
fun null [] = true | null _ = false
Comments
Post a Comment