From d81518114edf86917b51bb2b1e157eb695773b24 Mon Sep 17 00:00:00 2001 From: Christopher Schankula <schankuc@mcmaster.ca> Date: Thu, 8 Feb 2018 14:18:28 -0500 Subject: [PATCH] a few little fixes we noticed today in class if you choose to make them :) --- Lectures/L16_FunctProgContinued/FunctProgContinued.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lectures/L16_FunctProgContinued/FunctProgContinued.tex b/Lectures/L16_FunctProgContinued/FunctProgContinued.tex index c0c85081..ba38fc5b 100755 --- a/Lectures/L16_FunctProgContinued/FunctProgContinued.tex +++ b/Lectures/L16_FunctProgContinued/FunctProgContinued.tex @@ -180,7 +180,7 @@ list(map(add3, [1, 5, 3, 1, 6])) \item Write a function \texttt{repit(xs)} that takes a list \texttt{xs} and produces a new list that replicates each entry 3 times \bi -\item \texttt{[1, 2, 3]} $\rightarrow$ \texttt{[1, 1, 1], [2, 2, 2], [3, 3, 3]} +\item \texttt{[1, 2, 3]} $\rightarrow$ \texttt{[[1, 1, 1], [2, 2, 2], [3, 3, 3]]} \item $\mbox{map}: (a \rightarrow b) \times [a] \rightarrow [b]$ \item $\mbox{map}: (t \rightarrow [t]) \times [t] \rightarrow [[t]]$ \item $\mbox{rep}: t \times int \rightarrow [t]$ @@ -306,7 +306,7 @@ def even(x): \item \texttt{accum} is the initial value for the accumulator \item In Python 3 need \texttt{from functools import reduce} \item \structure{How would you use reduce to calculate the sum of the numbers - from 1 to 100?} + from 1 to 5?} \item \structure{How about the product?} \ei \end{frame} @@ -317,7 +317,7 @@ def even(x): \frametitle{Understanding Reduce for Sum} \bi -\item \texttt{reduce(lambda x, y: x+y, range(1, 5), 0)} +\item \texttt{reduce(lambda x, y: x+y, range(1, 6), 0)} \item \texttt{reduce(lambda x, y: x+y, [1, 2, 3, 4, 5], 0)} \item \texttt{((((0+1)+2)+3)+4)+5} \ei -- GitLab