sml - Is it possible to do pattern matching without case? -


i'm still learning sml, apologies if rather dumb question. wondering if there better way pattern matching on constructs outside of functions.

for example, let's have type

type coord = int * int * int 

and have value b of type coord. understand can pattern matching in functions, example:

fun get_x_coord ((x, y, z) : coord) = x 

but let's we're working b inside of function not given parameter. feel doing

case b of   (x,y,z) => (* stuff *) 

is rather clunky if have single result want (for example know there 3 integer values , want isolate them).

is there better way this?

sure - can use pattern matching in val-bindings too, this:

fun foo (b : coord) =   let val (x, y, z) = b   in (* stuff *)   end 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -