



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Pattern Recog Using Hid Markov; Subject: Computer Sci & Software Engr; University: Rose-Hulman Institute of Technology; Term: Unknown 1989;
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Curt Clifton Rose-Hulman Institute of Technology
Modules Pattern matching on data types Guards Testing Instance declarations Infix operators
data Pair a b = Pair a b twins :: Eq a => Pair a a -> String twins (Pair x y) | x == y = “yep” | otherwise = “nope” Matches a pair and binds x and y Guards work like case but use values instead of patterns Q
See sample code for testing depth
Surrounding binary function names with backticks lets us use them as infix operators: Hugs> 4 div 2 2 Surround infix operators with parentheses lets us declare their types: (<~) :: BinaryTree a -> BinaryTree a -> BinaryTree a _ <~ ExtNode = error "Can’t attach tree to ext. node" Q