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

Pages: 1-

QUICK! What's it do!

Name: Anonymous 2007-09-30 17:54 ID:s8J9Jad0

XXXXXX (aaa, bbb, ccc) = fXXXXXX 0 aaa bbb ccc
fXXXXXX n aaa bbb ccc = if (n>((length ccc)-(length aaa))) then ccc
else if (take (length aaa) (drop n ccc) == aaa) then fXXXXXX (n+(length bbb)) aaa bbb ((take n ccc)++bbb++(drop (n+(length aaa)) ccc))
else fXXXXXX (n+1) aaa bbb ccc

Name: Anonymous 2007-09-30 17:59 ID:eIt2oY5p

What's with the parens, mate?

Name: Anonymous 2007-09-30 18:01 ID:eIt2oY5p

And where's your indentation, jerk?

Name: Anonymous 2007-09-30 18:03 ID:s8J9Jad0

Why are you being too explicit but not explicit enough?  Is that what you are asking?

Name: Anonymous 2007-09-30 18:05 ID:s8J9Jad0

The real answer is I'm not very good at this, the second answer is that I copied it straight out of the notepad that opened up when I ftp'd it from the school's server.

Name: Anonymous 2007-09-30 22:22 ID:s8J9Jad0

C'mon, I thought you guys were great detectives.

Name: Anonymous 2007-09-30 22:28 ID:nraw5tIR

so, you want us to do your homework?

try rewriting it in a sane way to make it clearer

f n a b c | n > (length c - length a) = c
          | take (length a) (drop n c) == a = f (n + length b) a b ((take n c) ++ b ++ (drop (n + length a) c))
          | otherwise = f (n+1) a b c

Name: Anonymous 2007-09-30 22:35 ID:nraw5tIR

take this apart... "take (length a) (drop n c) == a" .. what do you think it means? first of all, this "drop then take" is a "slice/sublist" of the list c. so you could write this as "sublist n (length a) c"... which means: slice the list at position n, with length a. and then compares it to a. So "take (length a) (drop n c) == a" means "is the list 'a' a sublist of list 'c' starting at position n" ?

Name: Anonymous 2007-09-30 22:38 ID:nraw5tIR

...and I've given you enough clues already. I know what the algorithm does, but as a haskell aiding teacher (which I am, in an obscure university you probably don't know), I like to let my students think.

Name: Anonymous 2007-10-03 0:42

Man, get off your high horse dude.  I'm a fucking undergrad and that's my shitty code I wrote in 3 minutes.  I do agree that I formatted it like shit, but I didn't remember how to do the conditional cases at the time.

Regardless of that, you are an idiot for thinking my crappy code was some professors homework.

Name: Anonymous 2007-10-03 3:25

0wned

Name: Anonymous 2007-10-03 7:50

so you've never done algorithm recognition?

Name: Anonymous 2007-10-03 9:14

No, but I did recognition algorithms

Name: Anonymous 2011-02-03 1:53


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