Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
se2aa4_cs2me3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
W. Spencer Smith
se2aa4_cs2me3
Commits
d8151811
Commit
d8151811
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
a few little fixes we noticed today in class if you choose to make them :)
parent
acd93a0f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8
a few little fixes we noticed today in class if you choose to make them :)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Lectures/L16_FunctProgContinued/FunctProgContinued.tex
+3
-3
3 additions, 3 deletions
Lectures/L16_FunctProgContinued/FunctProgContinued.tex
with
3 additions
and
3 deletions
Lectures/L16_FunctProgContinued/FunctProgContinued.tex
+
3
−
3
View file @
d8151811
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment