<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi everyone,<BR>
&nbsp;<BR>
this is my first posting on here and this was what drove me here and the quest to know more as i anticipate a lot of help and direction in this quite new and different environment haskell.I have this paper that i'm working on and need to solve these scenarios/ cases based on&nbsp;some sample codes:<BR>
&nbsp;<BR>
Scenarios/cases:<BR>
&nbsp;<BR>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>1)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>Allow words to be hyphenated and treat the hyphenated word as a single word (including the hyphen).<SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-ALIGN: justify"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 2"><FONT face="Times New Roman" color=#000000 size=3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>2)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>As for no. 2 but if the hyphen is the last character on a line treat the hyphenated word as a single word without the hyphen.<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;</SPAN></FONT></FONT></SPAN></FONT><B style="mso-bidi-font-weight: normal"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><FONT face="Times New Roman"><SPAN style="mso-tab-count: 8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT></FONT></FONT></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-ALIGN: justify"><SPAN lang=EN-GB><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT face="Times New Roman" color=#000000 size=3></FONT></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>3)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>Treat a capitalised word (one or more capital letters) the <U>same</U> as lower case, i.e. only the lower case word appears in the index.<SPAN style="mso-tab-count: 1">&nbsp;</SPAN></FONT></FONT></SPAN></FONT><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><FONT face="Times New Roman"><SPAN style="mso-tab-count: 5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></FONT></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><FONT face="Times New Roman"><SPAN style="mso-spacerun: yes"></SPAN></FONT></FONT></FONT></SPAN><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>4)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>Treat a word ending in an ‘s’ as a plural and thus the same as the singular, i.e. only the singular appears in the index.<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-spacerun: yes"></SPAN></FONT></FONT></SPAN></FONT><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>5)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>As for no. 5 but (a) treat suffix ‘ss’ as not a plural; and (b) treat the plural suffixes ‘sses’, ‘zzes’, ‘oes’, ‘xes’, ‘shes’, ‘ches’ the same as the singular, i.e. without the ‘es’, e.g. “branches” (except for 4- and 5-letter plurals with suffices ‘oes’<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>and ‘ches’, e.g. “floes”, and 4-letter plural suffix ‘xes’); and (c) treat the plural suffix <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>‘ies’ (except for 4-letter plurals, e.g. “pies”) as the singular suffix ‘y’.<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></SPAN><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>6)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT color=#000000 size=3>Make the output more readable in the form of an index table.</FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></SPAN><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>7)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>Use an output file<SPAN style="mso-tab-count: 1">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-spacerun: yes"></SPAN></FONT></FONT></SPAN></FONT><FONT face="Times New Roman"><SPAN lang=EN-GB><SPAN style="mso-list: Ignore"><FONT color=#000000><FONT size=3>8)</FONT><SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN lang=EN-GB><FONT size=3><FONT color=#000000>Include a user-friendly menu by which the user can choose input and output file names.<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-tab-count: 1"></SPAN></FONT></FONT></SPAN></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-tab-count: 1"></SPAN></FONT></FONT></SPAN></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-tab-count: 1">This is the code i'm supposed tomodify and in some cases create new functions to support.I also need some explanation as the various approaches in solving them..............................................................................................</SPAN></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-tab-count: 1"></SPAN></FONT></FONT></SPAN></FONT>&nbsp;</P><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-tab-count: 1">
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; mso-outline-level: 1"><SPAN lang=EN-GB>The function <B>makeIndex </B>given a document produces a list of entries.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; mso-outline-level: 1"><SPAN lang=EN-GB>Each entry is a word and a list of line numbers (for words &gt; 4 letters)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Type definitions:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>import Prelude -- hiding (Word)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>--<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>predefined Word hidden, so we can define ours<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>type String<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[Char]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>defined in Prelude<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>type Doc<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>String<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>type Line<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>String<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>type Word<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>String<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>our version<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>makeIndex<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>::<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Doc<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>-&gt;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[ ([Int], Word) ]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; TEXT-ALIGN: justify"><SPAN lang=EN-GB style="mso-bidi-font-weight: bold">A data-directed design considers a sequence of functions (i.e using composition operator ‘.’) to transform the document of type, Doc, into an index of type, [ ([Int], Word) ].<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>splitUp<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></I><SPAN lang=EN-GB>the document, <I>doc</I>, into a list of lines, <I>[Line].</I><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>numLines<SPAN style="mso-tab-count: 1"> </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></I><SPAN lang=EN-GB>pairs each line with a line number, <I>[(Int, Line)].</I><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>allNumWords<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></I><SPAN lang=EN-GB>splits lines into words and line no., <I>[(Int, Word)].</I><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>sortLs<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></I><SPAN lang=EN-GB>sorts words into alphabetical order, <I>[(Int, Word)].</I><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>makeLists<SPAN style="mso-tab-count: 1">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></I><SPAN lang=EN-GB>makes a list for each line number, <I>[([Int], Word)].</I><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>amalgamate<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></I><SPAN lang=EN-GB>nos. into a list of nos. for each word, <I>[([Int], Word)].</I><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><I><SPAN lang=EN-GB>shorten</SPAN></I><SPAN lang=EN-GB><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>into a list for words &gt; 4 letters, <I>[([Int], Word)].<o:p></o:p></I></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>makeIndex<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= <SPAN style="mso-tab-count: 1">&nbsp; </SPAN>shorten .<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[([Int], Word)]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-&gt; [([Int], Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>amalgamate .<SPAN style="mso-tab-count: 1">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[([Int], Word)]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-&gt; [([Int], Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>makeLists .<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[(Int, Word)]<SPAN style="mso-tab-count: 1">&nbsp; </SPAN>-&gt; [([Int], Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>sortLs .<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[(Int, Word)]<SPAN style="mso-tab-count: 1">&nbsp; </SPAN>-&gt; [(Int, Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>allNumWords .<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[(Int, Line)]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>-&gt; [(Int, Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>numLines .<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[Line]<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-&gt; [(Int, Line)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>splitUp<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Doc<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-&gt; [Line]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Last<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[a]<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-&gt; [a ]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB>splitUp function</SPAN></U><U><SPAN style="mso-ansi-language: EN-US"><o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>splitUp :: Doc -&gt; [Line]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>splitUp [] = []<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>splitUp<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>text<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= takeWhile (/='\n') text :<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>first line<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>(splitUp . <SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>splitup other lines<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>dropWhile (==’\n’) . <SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>delete 1st newline(s)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>dropWhile (/='\n')) text<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>other lines <o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Example:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>splitUp “hello world\n\nnext world”</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>=&gt;<SPAN style="mso-tab-count: 1">&nbsp; </SPAN>[“hello world”, “next world”]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB>numLines function:</SPAN></U><U><SPAN style="mso-ansi-language: EN-US"><o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>numLines :: [Line] -&gt; [(Int, Line)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>numLines lines<SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>list of pairs of <o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= zip [1 .. length lines] lines<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>line no. &amp; line<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Example:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>numLines<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[“hello world”, “next world”]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>=&gt;<SPAN style="mso-tab-count: 1">&nbsp; </SPAN>[(1, “hello world”), (2, “next world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none"></SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none"></SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none"></SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none"></SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB>splitWords function:</SPAN></U><U><SPAN style="mso-ansi-language: EN-US"><o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>for each line<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>a)<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>split into words<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>b)<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>attach line no. to each word<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>splitWords :: Line -&gt; [Word]<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>a)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>splitWords [ ] = [ ]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>splitWords<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>line <o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= takeWhile isLetter line :<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>first word in line<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>(splitWords . <SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>split other words<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>dropWhile (not.isLetter &amp;&amp; Last ==’-’) . <SPAN style="mso-tab-count: 1"></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>delete separators<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>dropWhile isLetter) line<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>other words<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>where<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>isLetter ch<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>= <SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>(‘a’&lt;=ch) &amp;&amp; (ch&lt;=’z’)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN>|| (‘A’&lt;=ch) &amp;&amp; (ch&lt;=’Z’)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Example:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>splitWords<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>“hello world”<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>=&gt;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[“hello”, “world”]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>allNumWords function:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>numWords :: (Int, Line) -&gt; [(Int, Word)]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>b)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>numWords (number, line)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= map addLineNum ( splitWords line)<SPAN style="mso-tab-count: 1"> </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>all line pairs<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>where<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>addLineNum word = (number, word)<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>a pair<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>allNumWords :: [(Int, Line)] -&gt; [(Int, Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>allNumWords = concat . map numWords<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>doc pairs</SPAN></B><SPAN lang=EN-GB> </SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Examples:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>addLineNum<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>“hello” <SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=&gt;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>(1, “hello”)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>numWords<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>(1, “hello world”)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>=&gt;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[(1, “hello”), (1, “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>allNumWords [(1, “hello world”), (2, “next world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=&gt;<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[(1, “hello”), (1, “world”), (2, “next”), (2, “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.25in; mso-outline-level: 1"><U><SPAN lang=EN-GB>SortLs function:</SPAN></U><U><SPAN style="mso-ansi-language: EN-US"><o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>sortLs :: [(Int, Word)] -&gt; [(Int, Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>sortLs<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[ ]<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>=<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[ ]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>sortLs (a:x)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= sortLs [b | b &lt;- x, compare b a]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sort 1st half<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>++<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>[a]<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>++<SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>1st in middle<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>sortLs [b | b &lt;- x, compare a b]<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sort 2nd half<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>where<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>compare (n1, w1) (n2, w2)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>= (w1 &lt; w2) <SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>1st word less<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>|| (w1 == w2 &amp;&amp; n1 &lt; n2)<SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>check no.</SPAN></B><SPAN lang=EN-GB> </SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Example:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>sortLs [(1, “hello”), (1, “world”), (2, “next”), (2, “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>=&gt;<SPAN style="mso-tab-count: 1">&nbsp; </SPAN>[(1, “hello”), (2, “next”), (1, “world”), (2, “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB>makeLists function:</SPAN></U><U><SPAN style="mso-ansi-language: EN-US"><o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>makeLists :: [(Int, Word)] -&gt; [([Int], Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>makeLists <o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= map mk<SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>all pairs<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>where mk (num, word) = ([num], word)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>list of single no.</SPAN></B><SPAN lang=EN-GB> </SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Examples:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>mk<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>(1, “hello”)<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>=&gt;<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>([1], “hello”)</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>makeLists<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[(1, “hello”), (2, “next”), (1, “world”), (2, “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>=&gt;<SPAN style="mso-tab-count: 1">&nbsp; </SPAN>[([1], “hello”), ([2], “next”), ([1], “world”), ([2], “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; mso-outline-level: 1"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none">&nbsp;</SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; mso-outline-level: 1"><U><SPAN lang=EN-GB>Amalgamate function:<o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none">&nbsp;</SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>amalgamate :: [([Int], Word)] -&gt; [([Int], Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>amalgamate [ ] = [ ]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>amalgamate [a] = [a]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>amalgamate ((n1, w1) : (n2, w2) : rest)<SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-- <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>pairs of pairs<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>| w1 /= w2<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>= (n1, w1) : amalgamate ((n2, w2) : rest)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>| otherwise <SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>= amalgamate ((n1 ++ n2, w1) : rest)<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>if words are same grow list of numbers<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; mso-outline-level: 1"><B><SPAN lang=EN-GB>Example:<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>amalgamate<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN></B><SPAN lang=EN-GB>[([1], “hello”), ([2], “next”), ([1], “world”), ([2], “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>=&gt;<SPAN style="mso-tab-count: 1">&nbsp; </SPAN></SPAN></B><SPAN lang=EN-GB>[([1], “hello”), ([2], “next”), ([1, 2], “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none">&nbsp;</SPAN></o:p></SPAN></U></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in; mso-outline-level: 1"><U><SPAN lang=EN-GB>Shorten function:<o:p></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><U><SPAN lang=EN-GB><o:p><SPAN style="TEXT-DECORATION: none">&nbsp;</SPAN></o:p></SPAN></U></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>shorten :: [([Int], Word)] -&gt; [([Int], Word)]<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB>shorten<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>= filter long<SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>-- <SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>keep pairs &gt;4<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>where<o:p></o:p></SPAN></B></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><B><SPAN lang=EN-GB><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>long (num, word) = length word &gt; 4<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>--<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>check word &gt;4</SPAN></B><I><SPAN lang=EN-GB><o:p></o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><I><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB>Example:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN lang=EN-GB><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>shorten<I> <SPAN style="mso-spacerun: yes">&nbsp;</SPAN></I>[([1], “hello”), ([2], “next”), ([1, 2], “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><I><SPAN lang=EN-GB>=&gt;<SPAN style="mso-tab-count: 1"> </SPAN></SPAN></I><SPAN lang=EN-GB>[([1], “hello”), ([1, 2], “world”)]</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><I><SPAN lang=EN-GB><o:p>&nbsp;</o:p></SPAN></I></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="mso-ansi-language: EN-US"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"></SPAN></FONT></FONT></SPAN></FONT>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.5in; TEXT-ALIGN: justify; mso-list: l0 level1 lfo1; tab-stops: list .75in"><FONT face="Times New Roman"><SPAN lang=EN-GB><FONT size=3><FONT color=#000000><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN></FONT></FONT></SPAN></FONT>&nbsp;<BR></P><br /><hr />Connect to the next generation of MSN Messenger   <a href='http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline' target='_new'>Get it now! </a></body>
</html>