backup de julho
[h2N7SspZmY.git] / data / cache / 5 / 58ce5a4503c0e20677360bfe189090dd.code
blobbd0d9186a951235bdfbf84c12da867b85c2d3197
1 :l myfunctions <span class="co1">--load the functions in the file myfunctions.hs</span>
2 :r             <span class="co1">--reload</span>
3 &nbsp;
4 <span class="nu0">1</span> <span class="sy0">/=</span> <span class="nu0">0</span>         <span class="co1">--not equal</span>
5 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:succ"><span class="kw3">succ</span></a> <span class="nu0">0</span> <span class="sy0">==</span> <span class="nu0">1</span>    <span class="co1">--successor</span>
6 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:min"><span class="kw3">min</span></a> <span class="nu0">1</span> <span class="nu0">2</span> <span class="sy0">==</span> <span class="nu0">1</span>   <span class="co1">--minimum</span>
7 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:max"><span class="kw3">max</span></a> <span class="nu0">1</span> <span class="nu0">2</span> <span class="sy0">==</span> <span class="nu0">2</span>   <span class="co1">--maximum</span>
8 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"><span class="kw3">div</span></a> 2 1 <span class="sy0">==</span> 2 `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:div"><span class="kw3">div</span></a>` <span class="nu0">1</span> <span class="co1">--infix notation</span>
9 mysucc x <span class="sy0">=</span> x <span class="sy0">+</span> <span class="nu0">1</span>     <span class="co1">--function definition</span>
10 &nbsp;
11 <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="nu0">1</span>:<span class="nu0">2</span>:<span class="br0">&#91;</span><span class="br0">&#93;</span>     <span class="co1">--list definition</span>
12 <span class="st0">&quot;ab&quot;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="br0">&#93;</span>   <span class="co1">--string is [Char]</span>
13 <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">&#93;</span> <span class="sy0">++</span> <span class="br0">&#91;</span><span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">4</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">4</span><span class="br0">&#93;</span> <span class="co1">--list concatenation</span>
14 <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="br0">&#93;</span> <span class="sy0">!!</span> <span class="nu0">1</span> <span class="sy0">==</span> 'b'           <span class="co1">--list indexing</span>
15 &nbsp;
16 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> 1
17 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:tail"><span class="kw3">tail</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>2<span class="sy0">,</span> 3<span class="br0">&#93;</span>
18 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:init"><span class="kw3">init</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="br0">&#93;</span>
19 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span class="kw3">last</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> 3
20 l <span class="sy0">==</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a> l<span class="br0">&#41;</span>:<span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:tail"><span class="kw3">tail</span></a> l<span class="br0">&#41;</span> <span class="sy0">==</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:init"><span class="kw3">init</span></a> l<span class="br0">&#41;</span> <span class="sy0">++</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span class="kw3">last</span></a> l<span class="br0">&#41;</span>
21 &nbsp;
22 lenght <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="br0">&#93;</span> <span class="sy0">==</span> 2
23 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:null"><span class="kw3">null</span></a> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">==</span> True                  <span class="co1">--list is empty?</span>
24 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:reverse"><span class="kw3">reverse</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>3<span class="sy0">,</span> 2<span class="sy0">,</span> 1<span class="br0">&#93;</span>
25 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> <span class="nu0">2</span> <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="sy0">,</span> 'c'<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="br0">&#93;</span> <span class="co1">--first n elements of list</span>
26 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:drop"><span class="kw3">drop</span></a> <span class="nu0">2</span> <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="sy0">,</span> 'c'<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>'c'<span class="br0">&#93;</span>      <span class="co1">--drops n elements of list</span>
27 l <span class="sy0">==</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> n l<span class="br0">&#41;</span> <span class="sy0">++</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:drop"><span class="kw3">drop</span></a> n l<span class="br0">&#41;</span>
28 &nbsp;
29 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maximum"><span class="kw3">maximum</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> 3
30 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:minimum"><span class="kw3">minimum</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">&#93;</span> <span class="sy0">==</span> 1
31 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="sy0">,</span> 4<span class="br0">&#93;</span> <span class="sy0">==</span> 10
32 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:product"><span class="kw3">product</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="sy0">,</span> 4<span class="br0">&#93;</span> <span class="sy0">==</span> 24
33 2 `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:elem"><span class="kw3">elem</span></a>` <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span> <span class="sy0">==</span> True       <span class="co1">--element of the list?</span>
34 &nbsp;
35 <span class="br0">&#91;</span>1<span class="sy0">..</span>3<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span>
36 <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> 3<span class="sy0">..</span>10<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">5</span><span class="sy0">,</span> <span class="nu0">7</span><span class="sy0">,</span> <span class="nu0">9</span><span class="br0">&#93;</span>
37 <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> 3<span class="sy0">..</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> 5<span class="sy0">..</span><span class="br0">&#93;</span>          <span class="co1">--infinite list</span>
38 factorial n <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:product"><span class="kw3">product</span></a> <span class="br0">&#91;</span>1<span class="sy0">..</span>n<span class="br0">&#93;</span>
39 &nbsp;
40 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> <span class="nu0">24</span> <span class="br0">&#91;</span><span class="nu0">13</span><span class="sy0">,</span> 26<span class="sy0">..</span><span class="br0">&#93;</span>               <span class="co1">--the first 24 multiples of 13</span>
41 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> 7 <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:cycle"><span class="kw3">cycle</span></a> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">1</span><span class="br0">&#93;</span> <span class="co1">--cycle creates an infinite list</span>
42 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> 3 <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:repeat"><span class="kw3">repeat</span></a> 'a'<span class="br0">&#41;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'a'<span class="sy0">,</span> 'a'<span class="br0">&#93;</span>            <span class="co1">--repeat creates an infinite list</span>
43 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> n <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:repeat"><span class="kw3">repeat</span></a> x<span class="br0">&#41;</span> <span class="sy0">==</span> replicate n x
44 &nbsp;
45 <span class="br0">&#91;</span>x <span class="sy0">*</span> 2 <span class="sy0">|</span> x <span class="sy0">&lt;-</span> <span class="br0">&#91;</span>1 <span class="sy0">..</span> 10<span class="br0">&#93;</span><span class="sy0">,</span> 3 <span class="sy0">*</span> x <span class="sy0">&lt;</span> 7<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>2<span class="sy0">,</span> 4<span class="br0">&#93;</span>
46 <span class="br0">&#91;</span> x<span class="sy0">*</span>y <span class="sy0">|</span> x <span class="sy0">&lt;-</span> <span class="br0">&#91;</span>2<span class="sy0">,</span>5<span class="sy0">,</span>10<span class="br0">&#93;</span><span class="sy0">,</span> y <span class="sy0">&lt;-</span> <span class="br0">&#91;</span>8<span class="sy0">,</span>10<span class="sy0">,</span>11<span class="br0">&#93;</span><span class="sy0">,</span> x<span class="sy0">*</span>y <span class="sy0">&gt;</span> 50<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>55<span class="sy0">,</span>80<span class="sy0">,</span>100<span class="sy0">,</span>110<span class="br0">&#93;</span>
47 &nbsp;
48 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"><span class="kw3">length</span></a>' xs <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a> <span class="br0">&#91;</span>1 <span class="sy0">|</span> <span class="sy0">_</span> <span class="sy0">&lt;-</span> xs<span class="br0">&#93;</span>
49 removeNonUppercase st <span class="sy0">=</span> <span class="br0">&#91;</span> c <span class="sy0">|</span> c <span class="sy0">&lt;-</span> st<span class="sy0">,</span> c `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:elem"><span class="kw3">elem</span></a>` <span class="br0">&#91;</span>'A'<span class="sy0">..</span>'Z'<span class="br0">&#93;</span><span class="br0">&#93;</span>
50 &nbsp;
51 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fst"><span class="kw3">fst</span></a> <span class="br0">&#40;</span>1<span class="sy0">,</span> 'a'<span class="br0">&#41;</span> <span class="sy0">==</span> 1
52 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:snd"><span class="kw3">snd</span></a> <span class="br0">&#40;</span>1<span class="sy0">,</span> 'a'<span class="br0">&#41;</span> <span class="sy0">==</span> 'a'
53 <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fst"><span class="kw3">fst</span></a> x<span class="sy0">,</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:snd"><span class="kw3">snd</span></a> x<span class="br0">&#41;</span> <span class="sy0">==</span> x
54 &nbsp;
55 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"><span class="kw3">zip</span></a> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">&#93;</span> <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> 'a'<span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="nu0">2</span><span class="sy0">,</span> 'b'<span class="br0">&#41;</span><span class="br0">&#93;</span>
56 :t <span class="st0">&quot;HI&quot;</span> <span class="sy0">==</span> <span class="st0">&quot;HI&quot;</span> <span class="sy0">::</span> <span class="br0">&#91;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Char"><span class="kw4">Char</span></a><span class="br0">&#93;</span>                         <span class="co1">--type</span>
57 removeNonUppercase <span class="sy0">::</span> <span class="br0">&#91;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Char"><span class="kw4">Char</span></a><span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Char"><span class="kw4">Char</span></a><span class="br0">&#93;</span>            <span class="co1">--function type declaration</span>
58 :t <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a> <span class="sy0">==</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a> <span class="sy0">::</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> a                       <span class="co1">--type variable &quot;a&quot;</span>
59 :t <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:elem"><span class="kw3">elem</span></a> <span class="sy0">==</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:elem"><span class="kw3">elem</span></a> <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Eq"><span class="kw4">Eq</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Bool"><span class="kw4">Bool</span></a>     <span class="co1">--type class &quot;Eq&quot;</span>
60 &nbsp;
61 5 `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:compare"><span class="kw3">compare</span></a>` 3 <span class="sy0">==</span> GT
62 &nbsp;
63 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:show"><span class="kw3">show</span></a> <span class="nu0">5.334</span> <span class="sy0">==</span> <span class="st0">&quot;5.334&quot;</span>                             <span class="co1">--to string</span>
64 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:read"><span class="kw3">read</span></a> <span class="st0">&quot;[1, 2, 3]&quot;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span>                     <span class="co1">--from string</span>
65 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:read"><span class="kw3">read</span></a> <span class="st0">&quot;5&quot;</span> <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Float"><span class="kw4">Float</span></a>                                 <span class="co1">--type anotation</span>
66 &nbsp;
67 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:minBound"><span class="kw3">minBound</span></a> <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span class="kw4">Int</span></a> <span class="sy0">==</span> <span class="sy0">-</span>2147483648
68 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maxBound"><span class="kw3">maxBound</span></a> <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span class="kw4">Int</span></a> <span class="sy0">==</span> 2147483647
69 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fromIntegral"><span class="kw3">fromIntegral</span></a> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"><span class="kw3">length</span></a> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">2</span><span class="sy0">,</span><span class="nu0">3</span><span class="sy0">,</span><span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">3.2</span> <span class="sy0">==</span> <span class="nu0">7.2</span>      <span class="co1">--integral to float</span>
70 &nbsp;
71 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a>' <span class="sy0">::</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> a  
72 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a>' <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:error"><span class="kw3">error</span></a> <span class="st0">&quot;Can't call head on an empty list, dummy!&quot;</span>  <span class="co1">--run-time error</span>
73 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a>' <span class="br0">&#40;</span>x:<span class="sy0">_</span><span class="br0">&#41;</span> <span class="sy0">=</span> x  
74 &nbsp;
75 capital <span class="sy0">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span class="kw4">String</span></a> <span class="sy0">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span class="kw4">String</span></a>  
76 capital <span class="st0">&quot;&quot;</span> <span class="sy0">=</span> <span class="st0">&quot;Empty string, whoops!&quot;</span>  
77 capital <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:all"><span class="kw3">all</span></a><span class="sy0">@</span><span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">&quot;The first letter of &quot;</span> <span class="sy0">++</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:all"><span class="kw3">all</span></a> <span class="sy0">++</span> <span class="st0">&quot; is &quot;</span> <span class="sy0">++</span> <span class="br0">&#91;</span>x<span class="br0">&#93;</span> <span class="co1">--as pattern</span>
78 &nbsp;
79 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:max"><span class="kw3">max</span></a>' <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Ord"><span class="kw4">Ord</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> a <span class="sy0">-&gt;</span> a  
80 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:max"><span class="kw3">max</span></a>' a b   
81   <span class="sy0">|</span> a <span class="sy0">&gt;</span> b     <span class="sy0">=</span> a  <span class="co1">--guard</span>
82   <span class="sy0">|</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise"><span class="kw3">otherwise</span></a> <span class="sy0">=</span> b  <span class="co1">--otherwise = True</span>
83 &nbsp;
84 bmiTell <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:RealFloat"><span class="kw4">RealFloat</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> a <span class="sy0">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span class="kw4">String</span></a>  
85 bmiTell weight height  
86   <span class="sy0">|</span> bmi <span class="sy0">&lt;=</span> skinny <span class="sy0">=</span> <span class="st0">&quot;You're underweight, you emo, you!&quot;</span>  
87   <span class="sy0">|</span> bmi <span class="sy0">&lt;=</span> normal <span class="sy0">=</span> <span class="st0">&quot;You're supposedly normal. Pffft, I bet you're ugly!&quot;</span>  
88   <span class="sy0">|</span> bmi <span class="sy0">&lt;=</span> fat    <span class="sy0">=</span> <span class="st0">&quot;You're fat! Lose some weight, fatty!&quot;</span>  
89   <span class="sy0">|</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise"><span class="kw3">otherwise</span></a>     <span class="sy0">=</span> <span class="st0">&quot;You're a whale, congratulations!&quot;</span>
90   <span class="kw1">where</span> bmi <span class="sy0">=</span> weight <span class="sy0">/</span> height <span class="sy0">^</span> 2  
91         <span class="br0">&#40;</span>skinny<span class="sy0">,</span> normal<span class="sy0">,</span> fat<span class="br0">&#41;</span> <span class="sy0">=</span> <span class="br0">&#40;</span>18<span class="sy0">.</span>5<span class="sy0">,</span> 25<span class="sy0">.</span>0<span class="sy0">,</span> 30<span class="sy0">.</span>0<span class="br0">&#41;</span>  
92 &nbsp;
93 cylinderSurfaceArea <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:RealFloat"><span class="kw4">RealFloat</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> a <span class="sy0">-&gt;</span> a  
94 cylinderSurfaceArea r h <span class="sy0">=</span> 
95   <span class="kw1">let</span> sideArea <span class="sy0">=</span> 2 <span class="sy0">*</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:pi"><span class="kw3">pi</span></a> <span class="sy0">*</span> r <span class="sy0">*</span> h  
96       topArea <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:pi"><span class="kw3">pi</span></a> <span class="sy0">*</span> r <span class="sy0">^</span> 2  
97   <span class="kw1">in</span>  sideArea <span class="sy0">+</span> 2 <span class="sy0">*</span> topArea   
98 &nbsp;
99 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a>' <span class="sy0">::</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> a
100 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a>' xs <span class="sy0">=</span> <span class="kw1">case</span> xs <span class="kw1">of</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:error"><span class="kw3">error</span></a> <span class="st0">&quot;No head for empty lists!&quot;</span>
101                       <span class="br0">&#40;</span>x:<span class="sy0">_</span><span class="br0">&#41;</span> <span class="sy0">-&gt;</span> x
102 &nbsp;
103 quicksort <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Ord"><span class="kw4">Ord</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span>  
104 quicksort <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>  
105 quicksort <span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="sy0">=</span>   
106   <span class="kw1">let</span> smallerSorted <span class="sy0">=</span> quicksort <span class="br0">&#91;</span>a <span class="sy0">|</span> a <span class="sy0">&lt;-</span> xs<span class="sy0">,</span> a <span class="sy0">&lt;=</span> x<span class="br0">&#93;</span>  
107       biggerSorted <span class="sy0">=</span> quicksort <span class="br0">&#91;</span>a <span class="sy0">|</span> a <span class="sy0">&lt;-</span> xs<span class="sy0">,</span> a <span class="sy0">&gt;</span> x<span class="br0">&#93;</span>  
108   <span class="kw1">in</span>  smallerSorted <span class="sy0">++</span> <span class="br0">&#91;</span>x<span class="br0">&#93;</span> <span class="sy0">++</span> biggerSorted
109 &nbsp;
110 divideByTen <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Floating"><span class="kw4">Floating</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> a  
111 divideByTen <span class="sy0">=</span> <span class="br0">&#40;</span><span class="sy0">/</span><span class="nu0">10</span><span class="br0">&#41;</span>                    <span class="co1">--section, infix function partial application</span>
112 &nbsp;
113 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a>' <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> b <span class="sy0">-&gt;</span> c<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>b<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>c<span class="br0">&#93;</span>  
114 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a>' <span class="sy0">_</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">_</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>  
115 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a>' <span class="sy0">_</span> <span class="sy0">_</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>  
116 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a>' f <span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="br0">&#40;</span>y:ys<span class="br0">&#41;</span> <span class="sy0">=</span> f x y : <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a>' f xs ys
117 &nbsp;
118 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> b<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>b<span class="br0">&#93;</span>  
119 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="sy0">_</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>  
120 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> f <span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="sy0">=</span> f x : <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> f xs
121 &nbsp;
122 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Bool"><span class="kw4">Bool</span></a><span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span>  
123 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> <span class="sy0">_</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>  
124 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> p <span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span>   
125   <span class="sy0">|</span> p x       <span class="sy0">=</span> x : <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> p xs  
126   <span class="sy0">|</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise"><span class="kw3">otherwise</span></a> <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> p xs
127 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> p l <span class="sy0">==</span> <span class="br0">&#91;</span>x <span class="sy0">|</span> x <span class="sy0">&lt;-</span> l<span class="sy0">,</span> p x<span class="br0">&#93;</span>
128 &nbsp;
129 quicksort <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Ord"><span class="kw4">Ord</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span>    
130 quicksort <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>    
131 quicksort <span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="sy0">=</span>     
132   <span class="kw1">let</span> smallerSorted <span class="sy0">=</span> quicksort <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> <span class="br0">&#40;</span><span class="sy0">&lt;=</span>x<span class="br0">&#41;</span> xs<span class="br0">&#41;</span>  
133       biggerSorted <span class="sy0">=</span> quicksort <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> <span class="br0">&#40;</span><span class="sy0">&gt;</span>x<span class="br0">&#41;</span> xs<span class="br0">&#41;</span>   
134   <span class="kw1">in</span>  smallerSorted <span class="sy0">++</span> <span class="br0">&#91;</span>x<span class="br0">&#93;</span> <span class="sy0">++</span> biggerSorted
135 &nbsp;
136 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a> <span class="br0">&#40;</span>takeWhile <span class="br0">&#40;</span><span class="sy0">&lt;</span>10000<span class="br0">&#41;</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:odd"><span class="kw3">odd</span></a> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span><span class="sy0">^</span><span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#91;</span>1<span class="sy0">..</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="co1">--sum of all odd squares that are smaller than 10,000</span>
137 &nbsp;
138 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a> <span class="br0">&#40;</span><span class="sy0">+</span><span class="br0">&#41;</span> l r <span class="sy0">==</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zipWith"><span class="kw3">zipWith</span></a> <span class="br0">&#40;</span>\a b <span class="sy0">-&gt;</span> a <span class="sy0">+</span> b<span class="br0">&#41;</span> l r  <span class="co1">--lamba function</span>
139 &nbsp;
140 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a>' <span class="sy0">::</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Num"><span class="kw4">Num</span></a> a<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> a  
141 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a>' xs <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldl"><span class="kw3">foldl</span></a> <span class="br0">&#40;</span>\acc x <span class="sy0">-&gt;</span> acc <span class="sy0">+</span> x<span class="br0">&#41;</span> 0 xs
142 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a> <span class="sy0">==</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldl"><span class="kw3">foldl</span></a> <span class="br0">&#40;</span><span class="sy0">+</span><span class="br0">&#41;</span> 0
143 &nbsp;
144 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:elem"><span class="kw3">elem</span></a>' y ys <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldl"><span class="kw3">foldl</span></a> <span class="br0">&#40;</span>\acc x <span class="sy0">-&gt;</span> acc <span class="sy0">||</span> x <span class="sy0">==</span> y<span class="br0">&#41;</span> False ys
145 &nbsp;
146 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a>' <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> b<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>b<span class="br0">&#93;</span>
147 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a>' f xs <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldr"><span class="kw3">foldr</span></a> <span class="br0">&#40;</span>\x acc <span class="sy0">-&gt;</span> f x : acc<span class="br0">&#41;</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> xs
148 &nbsp;
149 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a>' <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Bool"><span class="kw4">Bool</span></a><span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span>  
150 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:filter"><span class="kw3">filter</span></a>' p <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldr"><span class="kw3">foldr</span></a> <span class="br0">&#40;</span>\x acc <span class="sy0">-&gt;</span> <span class="kw1">if</span> p x <span class="kw1">then</span> x : acc <span class="kw1">else</span> acc<span class="br0">&#41;</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>
151 &nbsp;
152 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:scanl"><span class="kw3">scanl</span></a> <span class="br0">&#40;</span><span class="sy0">+</span><span class="br0">&#41;</span> <span class="nu0">0</span> <span class="br0">&#91;</span><span class="nu0">3</span><span class="sy0">,</span><span class="nu0">5</span><span class="sy0">,</span><span class="nu0">2</span><span class="sy0">,</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">3</span><span class="sy0">,</span><span class="nu0">8</span><span class="sy0">,</span><span class="nu0">10</span><span class="sy0">,</span><span class="nu0">11</span><span class="br0">&#93;</span>  <span class="co1">--fold that keeps partial results</span>
153 &nbsp;
154 <span class="br0">&#40;</span><span class="sy0">$</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> b<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> a <span class="sy0">-&gt;</span> b  
155 f <span class="sy0">$</span> x <span class="sy0">=</span> f x                             <span class="co1">--function application function</span>
156 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span><span class="sy0">$</span> <span class="nu0">3</span><span class="br0">&#41;</span> <span class="br0">&#91;</span><span class="br0">&#40;</span><span class="nu0">4</span><span class="sy0">+</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="nu0">10</span><span class="sy0">*</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="sy0">^</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">7</span><span class="sy0">,</span> <span class="nu0">30</span><span class="sy0">,</span> <span class="nu0">9</span><span class="br0">&#93;</span> <span class="co1">--mapping function application</span>
157 &nbsp;
158 <span class="br0">&#40;</span><span class="sy0">.</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="br0">&#40;</span>b <span class="sy0">-&gt;</span> c<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> b<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> a <span class="sy0">-&gt;</span> c  
159 f <span class="sy0">.</span> g <span class="sy0">=</span> \x <span class="sy0">-&gt;</span> f <span class="br0">&#40;</span>g x<span class="br0">&#41;</span>                       <span class="co1">--function composition function</span>
160 &nbsp;
161 <span class="kw1">import</span> Data<span class="sy0">.</span>List                            <span class="co1">--import Data.List module</span>
162 :m <span class="sy0">+</span> Data<span class="sy0">.</span>List Data<span class="sy0">.</span>Map Data<span class="sy0">.</span>Set            <span class="co1">--import several modules</span>
163 <span class="kw1">import</span> Data<span class="sy0">.</span>List <span class="br0">&#40;</span>nub<span class="sy0">,</span> sort<span class="br0">&#41;</span>                <span class="co1">--import just nub and sort</span>
164 <span class="kw1">import</span> Data<span class="sy0">.</span>List <span class="kw1">hiding</span> <span class="br0">&#40;</span>nub<span class="br0">&#41;</span>               <span class="co1">--import all except nub</span>
165 <span class="kw1">import</span> <span class="kw1">qualified</span> Data<span class="sy0">.</span>Map                   <span class="co1">--force qualification</span>
166 <span class="kw1">import</span> <span class="kw1">qualified</span> Data<span class="sy0">.</span>Map <span class="kw1">as</span> M              <span class="co1">--force and rename qualification</span>
167 &nbsp;
168 <span class="coMULTI">{-
169   this is a
170   multiline comment
171 -}</span>
172 &nbsp;
173 intersperse <span class="nu0">0</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span>
174 intercalate <span class="st0">&quot; - &quot;</span> <span class="br0">&#91;</span><span class="st0">&quot;hey&quot;</span><span class="sy0">,</span><span class="st0">&quot;there&quot;</span><span class="sy0">,</span><span class="st0">&quot;guys&quot;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st0">&quot;hey - there - guys&quot;</span>
175 transpose <span class="br0">&#91;</span><span class="br0">&#91;</span>1<span class="sy0">,</span>2<span class="sy0">,</span>3<span class="br0">&#93;</span><span class="sy0">,</span><span class="br0">&#91;</span>4<span class="sy0">,</span>5<span class="sy0">,</span>6<span class="br0">&#93;</span><span class="sy0">,</span><span class="br0">&#91;</span>7<span class="sy0">,</span>8<span class="sy0">,</span>9<span class="br0">&#93;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>1<span class="sy0">,</span>4<span class="sy0">,</span>7<span class="br0">&#93;</span><span class="sy0">,</span><span class="br0">&#91;</span>2<span class="sy0">,</span>5<span class="sy0">,</span>8<span class="br0">&#93;</span><span class="sy0">,</span><span class="br0">&#91;</span>3<span class="sy0">,</span>6<span class="sy0">,</span>9<span class="br0">&#93;</span><span class="br0">&#93;</span>
176 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:concat"><span class="kw3">concat</span></a> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="br0">&#93;</span> <span class="br0">&#91;</span>3<span class="sy0">,</span> 4<span class="sy0">,</span> 5<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="sy0">,</span> 4<span class="sy0">,</span> 5<span class="br0">&#93;</span>
177 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:concatMap"><span class="kw3">concatMap</span></a>' f <span class="sy0">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:concat"><span class="kw3">concat</span></a> <span class="sy0">.</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> f
178 &nbsp;
179 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:and"><span class="kw3">and</span></a> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span><span class="sy0">&gt;</span>4<span class="br0">&#41;</span> <span class="br0">&#91;</span>5<span class="sy0">,</span>6<span class="sy0">,</span>7<span class="sy0">,</span>8<span class="br0">&#93;</span> <span class="sy0">==</span> True
180 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:or"><span class="kw3">or</span></a> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span><span class="sy0">&gt;</span>4<span class="br0">&#41;</span> <span class="br0">&#91;</span>1<span class="sy0">,</span>2<span class="sy0">,</span>3<span class="br0">&#93;</span> <span class="sy0">==</span> False
181 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:any"><span class="kw3">any</span></a> <span class="br0">&#40;</span><span class="sy0">==</span>4<span class="br0">&#41;</span> <span class="br0">&#91;</span>2<span class="sy0">,</span>3<span class="sy0">,</span>5<span class="sy0">,</span>6<span class="sy0">,</span>1<span class="sy0">,</span>4<span class="br0">&#93;</span> <span class="sy0">==</span> True
182 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:all"><span class="kw3">all</span></a> <span class="br0">&#40;</span><span class="sy0">==</span>4<span class="br0">&#41;</span> <span class="br0">&#91;</span>2<span class="sy0">,</span>3<span class="sy0">,</span>5<span class="sy0">,</span>6<span class="sy0">,</span>1<span class="sy0">,</span>4<span class="br0">&#93;</span> <span class="sy0">==</span> False
183 &nbsp;
184 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take"><span class="kw3">take</span></a> 4 <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:iterate"><span class="kw3">iterate</span></a> <span class="br0">&#40;</span><span class="sy0">*</span>2<span class="br0">&#41;</span> 1 <span class="sy0">==</span> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 4<span class="sy0">,</span> 8<span class="br0">&#93;</span>
185 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:splitAt"><span class="kw3">splitAt</span></a> <span class="nu0">3</span> <span class="st0">&quot;abcd&quot;</span> <span class="sy0">==</span> <span class="br0">&#40;</span><span class="st0">&quot;abc&quot;</span><span class="sy0">,</span><span class="st0">&quot;d&quot;</span><span class="br0">&#41;</span>
186 &nbsp;
187 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:dropWhile"><span class="kw3">dropWhile</span></a> <span class="br0">&#40;</span><span class="sy0">&lt;</span>3<span class="br0">&#41;</span> <span class="br0">&#91;</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="sy0">,</span> 4<span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span>3<span class="sy0">,</span> 4<span class="br0">&#93;</span>
188 <span class="br0">&#40;</span>takeWhile p l<span class="br0">&#41;</span> <span class="sy0">++</span> <span class="br0">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:dropWhile"><span class="kw3">dropWhile</span></a> p l<span class="br0">&#41;</span> <span class="sy0">==</span> l
189 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:span"><span class="kw3">span</span></a> p l <span class="sy0">==</span> <span class="br0">&#40;</span>takeWhile p l<span class="sy0">,</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:dropWhile"><span class="kw3">dropWhile</span></a> p l<span class="br0">&#41;</span>
190 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:break"><span class="kw3">break</span></a> p <span class="sy0">==</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:span"><span class="kw3">span</span></a> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:not"><span class="kw3">not</span></a> <span class="sy0">.</span> p
191 &nbsp;
192 sort <span class="br0">&#91;</span><span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span>
193 group <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="br0">&#91;</span><span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span><span class="sy0">,</span> <span class="br0">&#91;</span><span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#93;</span> <span class="co1">--group adjacent equals</span>
194 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span>\l<span class="sy0">@</span><span class="br0">&#40;</span>x:xs<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#40;</span>x<span class="sy0">,</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:length"><span class="kw3">length</span></a> l<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">.</span> group <span class="sy0">.</span> sort <span class="sy0">$</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#93;</span>  <span class="co1">--occurrences of each element</span>
195 &nbsp;
196 inits <span class="st0">&quot;w00t&quot;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="st0">&quot;&quot;</span><span class="sy0">,</span><span class="st0">&quot;w&quot;</span><span class="sy0">,</span><span class="st0">&quot;w0&quot;</span><span class="sy0">,</span><span class="st0">&quot;w00&quot;</span><span class="sy0">,</span><span class="st0">&quot;w00t&quot;</span><span class="br0">&#93;</span>
197 tails <span class="st0">&quot;w00t&quot;</span> <span class="sy0">==</span> <span class="br0">&#91;</span><span class="st0">&quot;w00t&quot;</span><span class="sy0">,</span><span class="st0">&quot;00t&quot;</span><span class="sy0">,</span><span class="st0">&quot;0t&quot;</span><span class="sy0">,</span><span class="st0">&quot;t&quot;</span><span class="sy0">,</span><span class="st0">&quot;&quot;</span><span class="br0">&#93;</span>
198 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:concat"><span class="kw3">concat</span></a> <span class="sy0">.</span> nub <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span>\<span class="br0">&#40;</span>x<span class="sy0">,</span> y<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> x <span class="sy0">++</span> y<span class="br0">&#41;</span> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"><span class="kw3">zip</span></a> <span class="br0">&#40;</span>inits w<span class="br0">&#41;</span> <span class="br0">&#40;</span>tails w<span class="br0">&#41;</span> <span class="sy0">==</span> w
199 &nbsp;
200 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:and"><span class="kw3">and</span></a> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span>`isPrefixOf` w<span class="br0">&#41;</span> <span class="br0">&#40;</span>inits w<span class="br0">&#41;</span> <span class="sy0">==</span> True
201 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:and"><span class="kw3">and</span></a> <span class="sy0">$</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:map"><span class="kw3">map</span></a> <span class="br0">&#40;</span>`isSuffixOf` w<span class="br0">&#41;</span> <span class="br0">&#40;</span>tails w<span class="br0">&#41;</span> <span class="sy0">==</span> True
202 <span class="br0">&#91;</span><span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="br0">&#93;</span> `isInfixOf` <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="sy0">,</span> <span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">4</span><span class="br0">&#93;</span> <span class="sy0">==</span> True