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

  1. yes, can, matched list won't empty, result of null function holds, i.e., [] :: [], equivalent [[]], not empty list.

  2. no, that's syntactically invalid. however, can shortened this:

fun null [] = true    | null _ = false 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -