Skip to content
Snippets Groups Projects
Commit b063622f authored by Timothée Jean Pascal Paul Floure's avatar Timothée Jean Pascal Paul Floure
Browse files

Merge branch 'setup' into 'master'

Website setup

See merge request lamp/cs-210-functional-programming-2019!1
parents ca75ce43 bad51154
No related branches found
No related tags found
No related merge requests found
Showing
with 267 additions and 2 deletions
# CS-210 Material This repository will be used as the website for Functional Programming CS-210. It will be updated weekly throughout the semester. This README contains general information about the class.
* [Moodle Page](https://moodle.epfl.ch/course/view.php?id=14257) - [previous-years-exams](https://gitlab.epfl.ch/lamp/cs210-material/week1/tree/master/previous-years-exams) contains PDFs for the 2016, 2017 and 2018 exams.
- [recitation-sessions](https://gitlab.epfl.ch/lamp/cs210-material/week1/tree/master/recitation-sessions) contains markdown documents for recitation sessions and solutions.
- [slides](https://gitlab.epfl.ch/lamp/cs210-material/week1/tree/master/slides
) contains the slides presented in class.
We will use GitLab's issue tracker as a discussion forum. Feel free to [open an issue](https://gitlab.epfl.ch/lamp/cs-210-functional-programming-2019/issues/new) if you have any comments or questions.
During the first week of the semester, you should will this Doodle to register to the recitation sessions:
- [https://doodle.com/poll/x3iyh8czww2pcat9](https://doodle.com/poll/x3iyh8czww2pcat9)
Also make sure to read the [instructions to install Git and Scala on your
machine](tools-setup.md), which are needed to complete the projects.
## Grading
The grading of the course is divided between projects (30%), a midterm (30%), and a final exam (40%) held during the last week of courses.
## Staff
| Role | People |
| :--- | :--- |
| Professors | Martin Odersky, Viktor Kunčak |
| TAs | Aleksander Boruch-Gruszecki, Guillaume Martres, Nicolas Stucki, Olivier Blanvillain, Periklis Chrysogelos |
| Student TAs | Artur Vignon, Haley Owsianko, Paul Renauld, Thomas De Chevigny, Timothée Floure |
## Rooms
Live lectures take place on Wednesdays from 13:15 to 15:00 in CO 2. Recitation sessions take place on Fridays from 10:15 to 12:00, where the room assignment is according to the Doodle linked above. Project sessions are held concurrently to the recitation sessions in CO 021.
## Lecture Schedule
| Week | Date | Topic |
| :-- | :-- | :-- |
| 1 | 18.09.2019 | Intro class |
| 2 | 25.09.2019 | Recursion |
| 3 | 02.10.2019 | Function values |
| 4 | 09.10.2019 | Classes |
| 5 | 16.10.2019 | Symbolic computations |
| 6 | 23.10.2019 | Collection |
| 7 | 30.10.2019 | Structural induction |
| 8 | 06.11.2019 | Monads |
| 9 | 13.11.2019 | State |
| 10 | 20.11.2019 | Constraints |
| 11 | 27.11.2019 | Lambda calculus / Lisp |
| 12 | 04.12.2019 | Scheme interpreter |
| 13 | 11.12.2019 | Prolog |
| 14 | 18.12.2019 | Review |
## Project Schedule
| Title | Start Date | Due Date (at noon) |
| :-- | :-- | :-- |
| Recursion | 18.09.2019 | 26.09.2019 |
| Functional Sets | 25.09.2019 | 03.10.2019 |
| Object-Oriented Sets | 02.10.2019 | 10.10.2019 |
| Huffman Coding | 09.10.2019 | 24.10.2019 |
| Anagrams | 16.10.2019 | 31.10.2019 |
| Bloxorz | 23.10.2019 | 07.11.2019 |
| Quickcheck | 30.10.2019 | 14.11.2019 |
| Calculator | 13.11.2019 | 28.11.2019 |
| Interpreter | 27.11.2019 | 18.12.2019 |
## Exam Schedule
The midterm exam will take place on Friday 08.11.2019 from 10:15 to 12:00.
The final exam will take place on Friday 20.12.2019 from 10:15 to 12:00.
Information about exam organization will be communicated by email a few days before each exam.
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
# Recitation Session 1
We will work on tail recursion in this session.
## Exercise 1: Factorial
Recall the factorial function that you saw in class
```scala
def factorial(n: Int): Int = if (n <= 0) 1 else n * factorial(n - 1)
```
Define a tail recursive version of it
```scala
def factorial(n: Int): Int = fact(n, 1)
@tailrec
def fact(n: Int, acc: Int): Int = ???
```
What would be the advantage of making `fact` an inner function to `factorial`?
## Exercise 2: Sum of elements on a list
Define a function that takes a list of integers and sums them. You can use the functions `head`, `tail`, and `isEmpty` on lists, as you have seen for your homework.
```scala
def sumList(ls: List[Int]): Int = ???
```
Convert your definition into a tail-recursive one.
## Exercise 3: Fast exponentiation
Fast exponentiation is a technique to optimize the exponentiation of numbers:
```
b²ⁿ = (b²)ⁿ = (bⁿ)²
b²ⁿ⁺¹ = b * b²ⁿ
```
Define a function that implements this fast exponentiation. Can you define a tail recursive version as well?
```scala
def fastExp(base: Int, exp: Int): Int = ???
```
## Exercise 4: Tail recursive Fibonacci
Define a function that computes the nth Fibonacci number. Can you define a tail recursive version as well? The Fibonacci recurrence is given as follows:
```
fib(n) = 1 | n = 0, 1
fib(n) = fib(n - 1) + fib(n - 2) | otherwise
```
```scala
def fibonacci(n: Int): Int = ???
```
# Tools Setup
# Step 1: Create an account on gitlab.epfl.ch
Go to [gitlab.epfl.ch](gitlab.epfl.ch) and log in with your EPFL account, do this as soon as
possible because it will take some time between the account creation and the
assignment submission system working for your account.
## Step 2: Installing the Java Development Kit (JDK)
### On Linux
#### On Ubuntu and Debian
```shell
sudo apt-get install openjdk-8-jdk
sudo update-java-alternatives --set /usr/lib/jvm/java-1.8.0-openjdk-amd64
```
#### On Fedora
```shell
sudo dnf install java-1.8.0-openjdk-devel
```
### On macOS
macOS either comes with a pre-installed JDK, or installs it automatically. To verify your JDK installation, open the Terminal and type `java -version`. If the JDK is not yet installed, the system will ask you if you would like to download and install it. Make sure you install Java 1.8.
### On Windows
[Download and run the JDK 8 installer for Windows from Oracle's website.](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
## Step 3: Verify your JDK installation
In a terminal, run:
```shell
java -version
```
The version number displayed on the first line should start with `1.8`. If this is not the case, then the wrong version of Java is on your `$PATH`.
See [https://www.java.com/en/download/help/path.xml](https://www.java.com/en/download/help/path.xml) for information on how to change this.
## Step 4: Installing sbt
`sbt` is the build tool we use to compile and run Scala programs.
### On Linux
See [https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html).
### On macOS
First, install Homebrew from [https://brew.sh](https://brew.sh) Then run:
```terminal
brew install sbt@1
```
### On Windows
Download and run [https://piccolo.link/sbt-1.2.7.msi](https://piccolo.link/sbt-1.2.7.msi)
## Step 5: Installing git
git is a version control system.
See [https://git-scm.com/book/en/v2/Getting-Started-Installing-Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
Once git is installed, please run:
```shell
git config --global core.autocrlf false
```
## Step 6: Installing VSCode
VSCode is the IDE we strongly recommend using for this class (you are free to use any editor you want, but we won't don't have the resources to help you configure it for Scala).
### On Linux
See [https://code.visualstudio.com/docs/setup/linux](https://code.visualstudio.com/docs/setup/linux)
### On macOS
See [https://code.visualstudio.com/docs/setup/mac](https://code.visualstudio.com/docs/setup/linux).
Make sure to follow both the "Installation" and "Launching from the Command Line" parts of the setup!
### On Windows
See [https://code.visualstudio.com/docs/setup/windows](https://code.visualstudio.com/docs/setup/linux).
Make sure that the checkbox "Add to PATH (available after restart)" in the installer is checked.
## Step 7: Verify your VSCode installation
Run:
```shell
code
```
VSCode is correctly installed if this opens a window, you can then close this window.
## Step 8: Generate a public/private SSH key pair
To submit assignments, you will need an SSH key. If you don't already have one, here's how to generate it:
### Installing OpenSSH
#### Ubuntu and Debian
```shell
sudo apt-get install openssh-client
```
#### macOS
Nothing to do, OpenSSH is pre-installed
#### Windows
The simplest solution is to have an up-to-date Windows 10 and follow [https://www.howtogeek.com/336775/how-to-enable-and-use-windows-10s-built-in-ssh-commands/](https://www.howtogeek.com/336775/how-to-enable-and-use-windows-10s-built-in-ssh-commands/).
### Generating the key pair
```shell
ssh-keygen -t rsa -b 4096 -C "youremail@example.com"
```
The command will then ask for a location, which you can leave as the default. It will then also ask for a passphrase to encrypt your private key, which you may leave empty. If you don't, make sure to remember your passphrase!
### Adding your public key on Gitlab
To be able to push your code, you'll need to add the public part of your key on Gitlab:
- Go to gitlab.epfl.ch, log in with your EPFL account
- Go to gitlab.epfl.ch/profile/keys and copy-paste the content of the `id_rsa.pub` file created by the `ssh-keygen` command you just ran (when the command was ran it printed the location where this file was saved).
- Press `Add key`
## Step 9: Follow the example assignment
The description of the example assignment (in your personnal gitlab repository) contains critical information to properly use the tools you just installed, don't miss it!
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment