haskell - Not in scope: data constructor simple code -


my first program in haskell doesn't compile:

removeodd nums =     if null nums     []     else          if mod (head nums) 2 == 0         (head nums) : (removeodd (tail nums))         else removeodd (tail nums)  main=removeodd [1,2,3,4,5,6,7,8]         

my.hs:1:1: not in scope: data constructor `removeodd'

my.hs:6:37: not in scope: data constructor `removeodd'

my.hs:7:22: not in scope: data constructor `removeodd'

my.hs:9:6: not in scope: data constructor `removeodd'

functions may not start uppercase letter. types, type constructors, classes, modules or data constructors may start uppercase letter:

removeodd nums =     if null nums     []     else          if mod (head nums) 2 == 0         (head nums) : (removeodd (tail nums))         else removeodd (tail nums)  main = removeodd [1,2,3,4,5,6,7,8] 

that being said, should have @ pattern matching, , filter, since removeodd = filter even.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -