Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell Help

Name: Anonymous 2008-10-25 19:41

Haskell beginner here. Anybody know how i shrink this down a bit, sorry I'd figure out myself but i'm sick of learning the same concepts in 20 different languages.

{-

type Month = String

validMonth :: Month -> Bool
validMonth "January" = True
validMonth "February" = True
validMonth "March" = True
validMonth "April" = True
validMonth "May" = True
validMonth "June" = True
validMonth "July" = True
validMonth "August" = True
validMonth "September" = True
validMonth "October" = True
validMonth "November" = True
validMonth "December" = True
validMonth _ = False

-}

Name: Anonymous 2008-10-25 20:56

Public Enum Months
 January
 February
 March
 April
 May
 June
 July
 August
 September
 October
 November
 December
End Enum

Yeah, I know is not Haskell, its a superior language.

Storing the name of the month as an array of strings in memory is gay and wasteful. There would be no point in a real language or a real program.

Need to get the name for output. If i is the desired month CType(i, Months).ToString

Need to check is some inputted integer is a valid month?
Months.IsDefined(GetType(Months), i)
Well i > 0 AndAlso <= 12 would be better.

I am sick of every fucking compsci teacher thinking that every fucking simple collection they see should be made in to a fucking array. A list of all the months is fucking constant. Does a list of constant values belong in a variable? Constant, variable. Understand the difference.

Seriously faggot, switch teachers to someone not so fucking stupid.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List