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

Pages: 1-

Haskell Questions

Name: Anonymous 2008-12-03 12:06

Sup dudes, a couple of Haskell questions:

- what is the meaning of "deriving Eq", in the end of a data type definition?

- is there any native Haskell function that giving String A, String B and Int C, to check if A is only made of B and only C times. "Ron" "RonRon" 2 -> True
I could swear I saw something like that in a substring shit

Name: Anonymous 2008-12-03 12:19

>>1
- what is the meaning of "deriving Eq", in the end of a data type definition?
Any elementary Haskell tutorial tells you this.

- is there any native Haskell function that giving String A, String B and Int C, to check if A is only made of B and only C times. "Ron" "RonRon" 2 -> True
I could swear I saw something like that in a substring shit

Hoogle tells you this.

Name: Anonymous 2008-12-03 12:31

>>2

I googled both things and I couldn't find anything.

Name: Anonymous 2008-12-03 12:37

>>3
Okay, just found Hoggle, via a link inside one of the Google entries. http://www.haskell.org/hoogle/

I never knew this thing existed. I searched for substring but couldn't find anything relevant. ~

Name: Anonymous 2008-12-03 13:02

Can't you write one yourself?

func A B C = A*C==B (or whatever operators haskell has, I'm not a haskell programmer, I only read Learn You a H.)

Name: Anonymous 2008-12-03 13:05

It's Hoogle not Hoggle you jew.

Name: Anonymous 2008-12-03 13:23

The Hoggles, they do nothing!

Name: Anonymous 2008-12-03 14:05

>>1
what is the meaning of "deriving Eq"
deriving Eq means your datatype is an instance of the typeclass specified. Each typeclass defines a list of ``instance functions'' which must be defined on every datatype which derives from that typeclass, for example

class Monad m where
    (>>=) :: forall a b. m a -> (a -> m b) -> m b
    return :: a -> m a


defines a Monad typeclass. If you derive a datatype from Monad, you're guarenteeing that there exists an implementation of (>>=) and return for your datatype.

In the case of Eq, Show and a couple others, the functions are generated automatically (``automatic derivation'') so you don't have to worry about actually implementing them, unless you want to specialize their functionality.

Eq, specifically, defines operations to check for equality (==) and inequality (/=).

hurf durf
hurf :: String -> String -> Int -> Bool
hurf a b c = foldl (\durf _ -> durf ++ b) "" [1..c] == a

Name: Anonymous 2008-12-03 14:06

Name: Anonymous 2008-12-03 14:39

hurf a b c = b == concat (replicate c a)

Name: Anonymous 2008-12-03 15:43

>>10
hurf a b c = b == concat $ replicate c a

Name: Anonymous 2008-12-04 1:43

loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap (\a -> a (loeb x)) x

Name: Anonymous 2008-12-04 9:10

>>12
loeb :: Functor a => a (a x -> x) -> a x
loeb x = fmap ($ loeb x) x

OMG OPTIMIZED

Name: Anonymous 2008-12-04 9:29

I'm apparently a colleague and he got the question wrong.

The function needed for that stuff is actually this:

test :: String -> String -> Int -> Bool
"String A, String B and Int C, to check if A is only made of B  (!! this B comes from a [String] inside the main program, so it's only True if there's B, but not the reast!!) and B only exists C times."

Yes, but you must test the other Strings.

A = "lolwrong"
B = "lol" , with ["lol","wut","moar"]
C = 1
True

if A was "lolwut", it would be False

Name: Anonymous 2008-12-04 9:54

>>14
This doesn't really make any sense

Name: Anonymous 2008-12-04 10:42

>>14
LERN 2 EXPLAIN THOUGHTS CLEARLY.

Name: Anonymous 2008-12-04 10:45

>>16
Haha. "Learn to be articulate".

Name: Anonymous 2008-12-04 11:09

>>17
yhbt.

Name: Anonymous 2008-12-04 19:59

>>15
>>16
>>17
>>18

14 here...
What the OP dude was talking about is this:

- he has to make a function that receives a String A, a String B, and an Int C.

test :: String -> String -> Int -> Bool
           A        B        C
- String B will be taken from a [String] available inside the program, say ZS (for instance made of [Z1,Z2,Z3,Z4,B,Z6,blabla]). I don't know how he is going to get this, but it's probably related with a data type he must do... I guess?

- on String A, OP must test if inside this String you can _only_ find the given String B, and not the other 'Z' friends AND if that is true, then B appears exactly C times, if not... False.

examples, with a fixed B of "lol", a fixed C is 2 and a fixed Z with ["lol","wut"]:
A: "lolomgguyslol" is True
A: "lollol" is True
A: "lolol" is False
A: "wutlollol" False

Row Row, Fight The Peyton.

Name: Anonymous 2008-12-04 23:26

>>19
"Be fresh and eager every morning, and tired and satisfied every night." -- Kent Beck

Name: Anonymous 2008-12-05 1:48

this thread grows ever more retarded

Name: Anonymous 2010-12-06 9:05

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2010-12-17 1:32

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-03 6:15

Name: Anonymous 2011-02-04 14:20


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