1 :l myfunctions <span class="co1">--load the functions in the file myfunctions.hs</span>
2 :r <span class="co1">--reload</span>
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>
11 <span class="br0">[</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">]</span> <span class="sy0">==</span> <span class="nu0">1</span>:<span class="nu0">2</span>:<span class="br0">[</span><span class="br0">]</span> <span class="co1">--list definition</span>
12 <span class="br0">[</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">]</span> <span class="sy0">++</span> <span class="br0">[</span><span class="nu0">3</span><span class="sy0">,</span> <span class="nu0">4</span><span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</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">]</span> <span class="co1">--list concatenation</span>
13 <span class="br0">[</span>'a'<span class="sy0">,</span> 'b'<span class="br0">]</span> <span class="sy0">!!</span> <span class="nu0">1</span> <span class="sy0">==</span> 'b' <span class="co1">--list indexing</span>
15 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> 1
16 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:tail"><span class="kw3">tail</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>2<span class="sy0">,</span> 3<span class="br0">]</span>
17 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:init"><span class="kw3">init</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="br0">]</span>
18 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:last"><span class="kw3">last</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> 3
19 l <span class="sy0">==</span> <span class="br0">(</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">)</span>:<span class="br0">(</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">)</span> <span class="sy0">==</span> <span class="br0">(</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">)</span> <span class="sy0">++</span> <span class="br0">(</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">)</span>
21 lenght <span class="br0">[</span>'a'<span class="sy0">,</span> 'b'<span class="br0">]</span> <span class="sy0">==</span> 2
22 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:null"><span class="kw3">null</span></a> <span class="br0">[</span><span class="br0">]</span> <span class="sy0">==</span> True <span class="co1">--list is empty?</span>
23 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:reverse"><span class="kw3">reverse</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>3<span class="sy0">,</span> 2<span class="sy0">,</span> 1<span class="br0">]</span>
24 <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">[</span>'a'<span class="sy0">,</span> 'b'<span class="sy0">,</span> 'c'<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>'a'<span class="sy0">,</span> 'b'<span class="br0">]</span> <span class="co1">--first n elements of list</span>
25 <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">[</span>'a'<span class="sy0">,</span> 'b'<span class="sy0">,</span> 'c'<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>'c'<span class="br0">]</span> <span class="co1">--drops n elements of list</span>
26 l <span class="sy0">==</span> <span class="br0">(</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">)</span> <span class="sy0">++</span> <span class="br0">(</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">)</span>
28 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:maximum"><span class="kw3">maximum</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> 3
29 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:minimum"><span class="kw3">minimum</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="br0">]</span> <span class="sy0">==</span> 1
30 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="sy0">,</span> 4<span class="br0">]</span> <span class="sy0">==</span> 10
31 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:product"><span class="kw3">product</span></a> <span class="br0">[</span>1<span class="sy0">,</span> 2<span class="sy0">,</span> 3<span class="sy0">,</span> 4<span class="br0">]</span> <span class="sy0">==</span> 24
32 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">[</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">]</span> <span class="sy0">==</span> True <span class="co1">--element of the list?</span>
34 <span class="br0">[</span>1<span class="sy0">..</span>3<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</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">]</span>
35 <span class="br0">[</span><span class="nu0">1</span><span class="sy0">,</span> 3<span class="sy0">..</span>10<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</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">]</span>
36 <span class="br0">[</span><span class="nu0">1</span><span class="sy0">,</span> 3<span class="sy0">..</span><span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</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">]</span> <span class="co1">--infinite list</span>
37 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">[</span>1<span class="sy0">..</span>n<span class="br0">]</span>
39 <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">[</span><span class="nu0">13</span><span class="sy0">,</span> 26<span class="sy0">..</span><span class="br0">]</span> <span class="co1">--the first 24 multiples of 13</span>
40 <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">(</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">[</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">]</span><span class="br0">)</span> <span class="sy0">==</span> <span class="br0">[</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">]</span> <span class="co1">--cycle creates an infinite list</span>
41 <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">(</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">)</span> <span class="sy0">==</span> <span class="br0">[</span>'a'<span class="sy0">,</span> 'a'<span class="sy0">,</span> 'a'<span class="br0">]</span> <span class="co1">--repeat 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> n <span class="br0">(</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">)</span> <span class="sy0">==</span> replicate n x
44 <span class="br0">[</span>x <span class="sy0">*</span> 2 <span class="sy0">|</span> x <span class="sy0"><-</span> <span class="br0">[</span>1 <span class="sy0">..</span> 10<span class="br0">]</span><span class="sy0">,</span> 3 <span class="sy0">*</span> x <span class="sy0"><</span> 7<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>2<span class="sy0">,</span> 4<span class="br0">]</span>
45 <span class="br0">[</span> x<span class="sy0">*</span>y <span class="sy0">|</span> x <span class="sy0"><-</span> <span class="br0">[</span>2<span class="sy0">,</span>5<span class="sy0">,</span>10<span class="br0">]</span><span class="sy0">,</span> y <span class="sy0"><-</span> <span class="br0">[</span>8<span class="sy0">,</span>10<span class="sy0">,</span>11<span class="br0">]</span><span class="sy0">,</span> x<span class="sy0">*</span>y <span class="sy0">></span> 50<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span>55<span class="sy0">,</span>80<span class="sy0">,</span>100<span class="sy0">,</span>110<span class="br0">]</span>
47 <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">[</span>1 <span class="sy0">|</span> <span class="sy0">_</span> <span class="sy0"><-</span> xs<span class="br0">]</span>
48 removeNonUppercase st <span class="sy0">=</span> <span class="br0">[</span> c <span class="sy0">|</span> c <span class="sy0"><-</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">[</span>'A'<span class="sy0">..</span>'Z'<span class="br0">]</span><span class="br0">]</span>
50 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fst"><span class="kw3">fst</span></a> <span class="br0">(</span>1<span class="sy0">,</span> 'a'<span class="br0">)</span> <span class="sy0">==</span> 1
51 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:snd"><span class="kw3">snd</span></a> <span class="br0">(</span>1<span class="sy0">,</span> 'a'<span class="br0">)</span> <span class="sy0">==</span> 'a'
52 <span class="br0">(</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">)</span> <span class="sy0">==</span> x
54 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip"><span class="kw3">zip</span></a> <span class="br0">[</span><span class="nu0">1</span><span class="sy0">,</span> <span class="nu0">2</span><span class="br0">]</span> <span class="br0">[</span>'a'<span class="sy0">,</span> 'b'<span class="br0">]</span> <span class="sy0">==</span> <span class="br0">[</span><span class="br0">(</span><span class="nu0">1</span><span class="sy0">,</span> 'a'<span class="br0">)</span><span class="sy0">,</span> <span class="br0">(</span><span class="nu0">2</span><span class="sy0">,</span> 'b'<span class="br0">)</span><span class="br0">]</span>
55 :t <span class="st0">"HI"</span> <span class="sy0">==</span> <span class="st0">"HI"</span> <span class="sy0">::</span> <span class="br0">[</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">]</span> <span class="co1">--type</span>
56 removeNonUppercase <span class="sy0">::</span> <span class="br0">[</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">]</span> <span class="sy0">-></span> <span class="br0">[</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">]</span> <span class="co1">--function type declaration</span>
57 :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">[</span>a<span class="br0">]</span> <span class="sy0">-></span> a <span class="co1">--type variable "a"</span>
58 :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">(</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">)</span> <span class="sy0">=></span> a <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span> <span class="sy0">-></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 "Eq"</span>
60 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 <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">"5.334"</span> <span class="co1">--to string</span>
63 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:read"><span class="kw3">read</span></a> <span class="st0">"[1, 2, 3]"</span> <span class="sy0">==</span> <span class="br0">[</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">]</span> <span class="co1">--from 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">"5"</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 <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
67 <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
68 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:fromIntegral"><span class="kw3">fromIntegral</span></a> <span class="br0">(</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">[</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">]</span><span class="br0">)</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 <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">[</span>a<span class="br0">]</span> <span class="sy0">-></span> a
71 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span class="kw3">head</span></a>' <span class="br0">[</span><span class="br0">]</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">"Can't call head on an empty list, dummy!"</span> <span class="co1">--run-time error</span>
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">(</span>x:<span class="sy0">_</span><span class="br0">)</span> <span class="sy0">=</span> x
74 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">-></span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:String"><span class="kw4">String</span></a>
75 capital <span class="st0">""</span> <span class="sy0">=</span> <span class="st0">"Empty string, whoops!"</span>
76 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">(</span>x:xs<span class="br0">)</span> <span class="sy0">=</span> <span class="st0">"The first letter of "</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">" is "</span> <span class="sy0">++</span> <span class="br0">[</span>x<span class="br0">]</span> <span class="co1">--as pattern</span>
78 <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">(</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">)</span> <span class="sy0">=></span> a <span class="sy0">-></span> a <span class="sy0">-></span> a
79 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:max"><span class="kw3">max</span></a>' a b
80 <span class="sy0">|</span> a <span class="sy0">></span> b <span class="sy0">=</span> a <span class="co1">--guard</span>
81 <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 bmiTell <span class="sy0">::</span> <span class="br0">(</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">)</span> <span class="sy0">=></span> a <span class="sy0">-></span> a <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>
85 <span class="sy0">|</span> bmi <span class="sy0"><=</span> skinny <span class="sy0">=</span> <span class="st0">"You're underweight, you emo, you!"</span>
86 <span class="sy0">|</span> bmi <span class="sy0"><=</span> normal <span class="sy0">=</span> <span class="st0">"You're supposedly normal. Pffft, I bet you're ugly!"</span>
87 <span class="sy0">|</span> bmi <span class="sy0"><=</span> fat <span class="sy0">=</span> <span class="st0">"You're fat! Lose some weight, fatty!"</span>
88 <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">"You're a whale, congratulations!"</span>
89 <span class="kw1">where</span> bmi <span class="sy0">=</span> weight <span class="sy0">/</span> height <span class="sy0">^</span> 2
90 <span class="br0">(</span>skinny<span class="sy0">,</span> normal<span class="sy0">,</span> fat<span class="br0">)</span> <span class="sy0">=</span> <span class="br0">(</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">)</span>
92 cylinderSurfaceArea <span class="sy0">::</span> <span class="br0">(</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">)</span> <span class="sy0">=></span> a <span class="sy0">-></span> a <span class="sy0">-></span> a
93 cylinderSurfaceArea r h <span class="sy0">=</span>
94 <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
95 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
96 <span class="kw1">in</span> sideArea <span class="sy0">+</span> 2 <span class="sy0">*</span> topArea
98 <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">[</span>a<span class="br0">]</span> <span class="sy0">-></span> a
99 <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">[</span><span class="br0">]</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">"No head for empty lists!"</span>
100 <span class="br0">(</span>x:<span class="sy0">_</span><span class="br0">)</span> <span class="sy0">-></span> x
102 quicksort <span class="sy0">::</span> <span class="br0">(</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">)</span> <span class="sy0">=></span> <span class="br0">[</span>a<span class="br0">]</span> <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span>
103 quicksort <span class="br0">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">[</span><span class="br0">]</span>
104 quicksort <span class="br0">(</span>x:xs<span class="br0">)</span> <span class="sy0">=</span>
105 <span class="kw1">let</span> smallerSorted <span class="sy0">=</span> quicksort <span class="br0">[</span>a <span class="sy0">|</span> a <span class="sy0"><-</span> xs<span class="sy0">,</span> a <span class="sy0"><=</span> x<span class="br0">]</span>
106 biggerSorted <span class="sy0">=</span> quicksort <span class="br0">[</span>a <span class="sy0">|</span> a <span class="sy0"><-</span> xs<span class="sy0">,</span> a <span class="sy0">></span> x<span class="br0">]</span>
107 <span class="kw1">in</span> smallerSorted <span class="sy0">++</span> <span class="br0">[</span>x<span class="br0">]</span> <span class="sy0">++</span> biggerSorted
109 divideByTen <span class="sy0">::</span> <span class="br0">(</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">)</span> <span class="sy0">=></span> a <span class="sy0">-></span> a
110 divideByTen <span class="sy0">=</span> <span class="br0">(</span><span class="sy0">/</span><span class="nu0">10</span><span class="br0">)</span> <span class="co1">--section, infix function partial application</span>
112 <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">(</span>a <span class="sy0">-></span> b <span class="sy0">-></span> c<span class="br0">)</span> <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span> <span class="sy0">-></span> <span class="br0">[</span>b<span class="br0">]</span> <span class="sy0">-></span> <span class="br0">[</span>c<span class="br0">]</span>
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">[</span><span class="br0">]</span> <span class="sy0">_</span> <span class="sy0">=</span> <span class="br0">[</span><span class="br0">]</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="sy0">_</span> <span class="br0">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">[</span><span class="br0">]</span>
115 <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">(</span>x:xs<span class="br0">)</span> <span class="br0">(</span>y:ys<span class="br0">)</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 <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">(</span>a <span class="sy0">-></span> b<span class="br0">)</span> <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span> <span class="sy0">-></span> <span class="br0">[</span>b<span class="br0">]</span>
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">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">[</span><span class="br0">]</span>
119 <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">(</span>x:xs<span class="br0">)</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 <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">(</span>a <span class="sy0">-></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">)</span> <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span> <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span>
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">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">[</span><span class="br0">]</span>
123 <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">(</span>x:xs<span class="br0">)</span>
124 <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
125 <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
126 <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">[</span>x <span class="sy0">|</span> x <span class="sy0"><-</span> l<span class="sy0">,</span> p x<span class="br0">]</span>
128 quicksort <span class="sy0">::</span> <span class="br0">(</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">)</span> <span class="sy0">=></span> <span class="br0">[</span>a<span class="br0">]</span> <span class="sy0">-></span> <span class="br0">[</span>a<span class="br0">]</span>
129 quicksort <span class="br0">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="br0">[</span><span class="br0">]</span>
130 quicksort <span class="br0">(</span>x:xs<span class="br0">)</span> <span class="sy0">=</span>
131 <span class="kw1">let</span> smallerSorted <span class="sy0">=</span> quicksort <span class="br0">(</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">(</span><span class="sy0"><=</span>x<span class="br0">)</span> xs<span class="br0">)</span>
132 biggerSorted <span class="sy0">=</span> quicksort <span class="br0">(</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">(</span><span class="sy0">></span>x<span class="br0">)</span> xs<span class="br0">)</span>
133 <span class="kw1">in</span> smallerSorted <span class="sy0">++</span> <span class="br0">[</span>x<span class="br0">]</span> <span class="sy0">++</span> biggerSorted
135 <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sum"><span class="kw3">sum</span></a> <span class="br0">(</span>takeWhile <span class="br0">(</span><span class="sy0"><</span>10000<span class="br0">)</span> <span class="br0">(</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">(</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">(</span><span class="sy0">^</span><span class="nu0">2</span><span class="br0">)</span> <span class="br0">[</span>1<span class="sy0">..</span><span class="br0">]</span><span class="br0">)</span><span class="br0">)</span><span class="br0">)</span> <span class="co1">--sum of all odd squares that are smaller than 10,000</span>