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

Pages: 1-

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 19:42

Have an array of months and an array of booleans. Also, why are you using Haskell?

Name: Anonymous 2008-10-25 19:45

It's a class assignment, that's not how it would work, what's the point in two arrays, I could just have a hash map if i wanted to make things excessive. Don't know how to do arrays in Shitskell yet anyway.

Name: Anonymous 2008-10-25 20:13

data Month = January | February | March | April | May | June
             | July | August | September | October | November
             | December deriving (Read, Show, Eq, Ord)

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.

Name: Anonymous 2008-10-25 20:57

>>4
You should probably derive Bounded, too.

Name: Anonymous 2008-10-25 21:31

>>5 doesn't know Haskell. Also,

AndAlso
What the fuck is this shit‽

Name: Anonymous 2008-10-25 21:58

>>7
AndAlso was created because VB's traditional boolean operators don't do short-circuiting.

Name: Anonymous 2008-10-25 22:02

>>8
So >>5 is VB? Good to know he was just trolling.

Name: Anonymous 2008-10-25 23:45

>>9

Nigger, the point about putting something as constant as the names of all of the months in an array variable as being fagishly stupid and terrible teaching was apt.

Name: Anonymous 2008-10-26 0:19

>>10
No it wasn't.  How the fuck are you supposed to validate a string when you don't know what would be an acceptable value?  And OP never even mentioned a fucking array.  And "inputted integer"?  What the fuck are you talking about?  Who's going to input a fucking integer?

Name: Anonymous 2008-10-26 0:35

>>11

Think a little. No program should ever have to compare the name of a month as a string. If anything, it might need the month as a integer.

OP didn't exapnd out what he was trying to do. But its obvious. Month name strings as valid. No proper program or UI is gonna ask that shit. Months are ints and outputted to humans as strings. No human readable date is ever expressed as a integers right? 10/25/2008. No INTEGERS, FUCK! Time on a computer is never epxressed as integers either. You x86 never tracks times as some integer value from some given date. Oh wait nigger it does.

You know what, fuck it. You are obviously a terrible programmer and explaining this is a waste of time. You continue to think that ever constant collection is variable and should be stored in a variable. Who knows, we might add a new month at any reasonable time in the future.

This is way beyond you dude.

Name: Anonymous 2008-10-26 1:02

>>12
Sorry, I can't think as little as you.  None of that shit you're babbling about has anything to do with the problem, the OP, or his teacher.  No one here is putting the months in a variable OR an array, and we're not designing a fucking enterprise data entry interface.

Name: Anonymous 2008-10-26 1:18

Gee it sure is first year computer science around here.
Haskell the Dog would be rolling in her grave if she saw what her precious /prog/ has turned into.

Name: Anonymous 2008-10-26 1:18

>>14
Forgot my sage.

Name: Anonymous 2008-10-26 3:25

>>14

/prog/ where a proper computer programming language implementation of a basic concept is called "enterprise" and dismissed.

You idiots can't understand real programming. Its why I get paid the big bucks, to fix your idiot fuck ups and wright correct code.

All of you are fucking Indians with 3rd world "programming" degrees.

Name: Anonymous 2008-10-26 5:27

All of you are fucking Indians with 3rd world "programming" degrees. All of you are fucking Indians with 3rd world "programming" degrees. All of you are fucking Indians with 3rd world "programming" degrees. All of you are fucking Indians with 3rd world "programming" degrees. All of you are fucking Indians with 3rd world "programming" degrees. All of you are fucking Indians with 3rd world "programming" degrees. All of you are fucking Indians with 3rd world "programming" degrees.

Name: Anonymous 2008-10-26 5:35

>>17
Damn right we are. And they better keep mum about it if they want to keep their H-1Bs

Name: Anonymous 2008-10-26 7:13

>>16
I don't even know who or what you're trying to argue against. I'm a bit worried about your mental health. Anyway, >>4,6 already provided the proper answer to the OP's question. Since you clearly know nothing about Haskell, why don't you just stay out of the discussion?

Name: Anonymous 2008-10-26 9:24

>>16
wright
hee hee hee

Name: Anonymous 2008-10-26 10:30

>>1
I fucking lol'd. EXPERT PROGRAMMER

Name: Anonymous 2008-10-26 10:44

All of you are fucking Indians with 3rd world "programming" degrees.
Back to vdare.com, please

Name: Anonymous 2010-12-17 1:30

Xarn is a bad boyfriend

Name: Anonymous 2011-02-04 12:49


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