Only the first constructor needs to be inspected:The first type parameter is the type of the first element in either algebraic data type. The source examples therefore return
headZig :: Zig a b -> a
headZig (Cins x _) = x
headZig Nil = error "headZig: empty input"
headZag :: Zag a b -> a
headZag (Cans x _) = x
headZag Nal = error "headZag: empty input"1 and "C", respectively. These functions are partial at empty inputs, as allowed by the stated nonempty-input requirement. Articles by others on the same topic
There are currently no matching articles.