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

HASKELL LIST HELP

Name: Anonymous 2011-01-12 11:54

HELLO

I HAVE A LIST sortList OF INTEGERS 1..n AND A LIST elemList OF n ELEMENTS. HERE'S WHAT I WANT TO DO:

sortList: [3,2,4,1]
elemList: ["HAX", "MY", "ANUS", "ONIICHAN"]

proggleSort sortList elemList
=>
["ANUS", "MY", "ONIICHAN" "HAX"]

HOW WOULD I IMPLEMENT THE proggleSort?

Name: Anonymous 2011-01-12 12:00

I'll assume you know how to progressively get each list element in order from first to last, how to append a new element to the end of a list, and basic file IO and string operations.

Take elemList and write each element to a text file, named 1.txt, 2.txt, and so on.

Then take sortList, convert each element to a string, append ".txt", open the corresponding file, and insert its contents onto the result list.

There are more elegant solutions to this problem, but this one will leave your teacher with little doubt it's your own work.

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