Skip to content

Commit

Permalink
update page
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjitjhala committed Nov 26, 2018
1 parent 4a51b99 commit 1eb50b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
12 changes: 3 additions & 9 deletions docs/lectures/07-egg-eater.html
Original file line number Diff line number Diff line change
Expand Up @@ -797,14 +797,8 @@ <h3 id="accessing-tuples">Accessing Tuples</h3>
<a class="sourceLine" id="cb24-2" data-line-number="2"> TODO<span class="op">-</span>IN<span class="op">-</span>CLASS</a></code></pre></div>
<h3 id="quiz">QUIZ</h3>
<p>Using the above “library” we can write code like:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode haskell"><code class="sourceCode haskell"><a class="sourceLine" id="cb25-1" data-line-number="1">def get(e, i)<span class="fu">:</span></a>
<a class="sourceLine" id="cb25-2" data-line-number="2"> <span class="kw">if</span> (i <span class="fu">==</span> <span class="dv">0</span>)<span class="fu">:</span></a>
<a class="sourceLine" id="cb25-3" data-line-number="3"> head(e)</a>
<a class="sourceLine" id="cb25-4" data-line-number="4"> <span class="kw">else</span><span class="fu">:</span></a>
<a class="sourceLine" id="cb25-5" data-line-number="5"> get(tail(e), i<span class="fu">-</span><span class="dv">1</span>)</a>
<a class="sourceLine" id="cb25-6" data-line-number="6"></a>
<a class="sourceLine" id="cb25-7" data-line-number="7"><span class="kw">let</span> quad <span class="fu">=</span> tup4(<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>) <span class="kw">in</span></a>
<a class="sourceLine" id="cb25-8" data-line-number="8"> get(quad, <span class="dv">0</span>) <span class="fu">+</span> get(quad, <span class="dv">1</span>) <span class="fu">+</span> get(quad, <span class="dv">2</span>) <span class="fu">+</span> get(quad, <span class="dv">3</span>)</a></code></pre></div>
<div class="sourceCode" id="cb25"><pre class="sourceCode haskell"><code class="sourceCode haskell"><a class="sourceLine" id="cb25-1" data-line-number="1"><span class="kw">let</span> quad <span class="fu">=</span> tup4(<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>) <span class="kw">in</span></a>
<a class="sourceLine" id="cb25-2" data-line-number="2"> get(quad, <span class="dv">0</span>) <span class="fu">+</span> get(quad, <span class="dv">1</span>) <span class="fu">+</span> get(quad, <span class="dv">2</span>) <span class="fu">+</span> get(quad, <span class="dv">3</span>)</a></code></pre></div>
<p>What will be the result of compiling the above?</p>
<ol type="1">
<li>Compile error</li>
Expand Down Expand Up @@ -896,7 +890,7 @@ <h2 id="recap">Recap</h2>
1:2:3:4:5:6:7:8:[]
(1,(2,(3,(4,(5,(6,(7,(8,false))))))))

def isEmpty(l):
def isEmpty(l):
l == false

def cons(h, t):
Expand Down
12 changes: 2 additions & 10 deletions lectures/07-egg-eater.md
Original file line number Diff line number Diff line change
Expand Up @@ -695,17 +695,12 @@ def get(t, i):
TODO-IN-CLASS
```


### QUIZ

Using the above "library" we can write code like:

```haskell
def get(e, i):
if (i == 0):
head(e)
else:
get(tail(e), i-1)

let quad = tup4(1, 2, 3, 4) in
get(quad, 0) + get(quad, 1) + get(quad, 2) + get(quad, 3)
```
Expand All @@ -718,9 +713,6 @@ What will be the result of compiling the above?
4. `4`
5. `10`




### QUIZ

Using the above "library" we can write code like:
Expand Down Expand Up @@ -849,7 +841,7 @@ data List = Node Int List -- (Int, List)
1:2:3:4:5:6:7:8:[]
(1,(2,(3,(4,(5,(6,(7,(8,false))))))))
def isEmpty(l):
def isEmpty(l):
l == false
def cons(h, t):
Expand Down

0 comments on commit 1eb50b8

Please sign in to comment.