backup de julho
[h2N7SspZmY.git] / data / cache / d / d9df1c56078b35860cef4fb1d8e3b2a8.code
blobaba6c860b3d625b0733e2661af73b513e6a45da0
1 :l myfunctions <span class="co1">--load the functions in the file myfunctions.hs</span>
2 :r             <span class="co1">--reload</span>
3 <span class="nu0">1</span> <span class="sy0">/=</span> <span class="nu0">0</span>         <span class="co1">--not equal</span>
4 <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>
5 <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>
6 <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>
7 <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>
8 mysucc x <span class="sy0">=</span> x <span class="sy0">+</span> <span class="nu0">1</span>     <span class="co1">--function definition</span>
9 <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>
10 <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>
11 <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>
12 <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
13 <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>
14 <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>
15 <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
16 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>
17 lenght <span class="br0">&#91;</span>'a'<span class="sy0">,</span> 'b'<span class="br0">&#93;</span> <span class="sy0">==</span> 2
18 <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>
19 <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>
20 <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>
21 <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>
22 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>
23 <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
24 <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
25 <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
26 <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
27 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>
28 <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>
29 <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>
30 <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>
31 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>
32 <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>
33 <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>
34 <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>
35 <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
36 <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>
37 <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>
38 <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>
39 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>
40 <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
41 <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'
42 <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
43 <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>
44 :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>
45 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>
46 :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>
47 :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>
48 5 `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:compare"><span class="kw3">compare</span></a>` <span class="nu0">3</span> <span class="sy0">==</span> GT