0
smallestNumberH (x:xs) n = if(xs==[])then n else (if(x<n) then smallestNumberH xs x else smallestNumberH xs n)
smallestNumber (x:xs) = smallestNumberH (x:xs) x
countmin::[Int]->Int
countmin l:ls = if (ls==[]) then 0 else (if(l==smallestNumber ls) then (1 + countmin ls) else (countmin ls))

It says "Parse error in pattern: countmin". I tried to add l: next to ls but it doesn't work.

amalloy
  • 89,153
  • 8
  • 140
  • 205
gprex
  • 67
  • 1
  • 2
  • 5
  • 1
    You also have some non-exhaustive patters. Try compiling with `-Wall` to see those before they cause runtime errors. – Chad Gilbert Mar 29 '16 at 18:03
  • If you want your helper function to only handle the case where there's at least one element, make that element a separate argument to the helper function so it's clear that it will always be there. Your main function should certainly handle the empty case somehow. – dfeuer Mar 29 '16 at 18:28
  • Possible duplicate of [Haskell: Parse error in pattern](https://stackoverflow.com/questions/8561762/haskell-parse-error-in-pattern) – Chris Martin Sep 06 '17 at 07:54

1 Answers1

1

You are missing parentheses around your pattern matching for countmin. Change it to:

countmin (l:ls) = ...
Chad Gilbert
  • 36,115
  • 4
  • 89
  • 97