Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think you've misunderstood my use of "pattern matching" in the post above. The way you've used it is a bit like saying "C is the best language for if statements".

A pattern match in ML is something like:

fun f 0 = <do something> | f 1 = <do something else> | f n = <do something in the general case

This goes really well with the ability to build up arbitrary datastructures, for example:

fun sum_tree (Node v) = v | sum_tree (Branch (left, v, right)) = v + sum_tree(left) + sum_tree(right)

Which would sum up all the values stored in an integer tree.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: