This is the repository of the course on Functional Programming in Scala taught at the University Rey Juan Carlos.
The course basically includes several notebooks on the following topics:
- PF-1.1 Object-oriented Scala
- PF-2.1 Functions and algebraic data types
- PF-2.2 Recursive functions and ADTs
- PF-2.3 The Curry-Howard correspondence
- PF-3.1 The Hall-of-Fame of HOFs
- PF-3.2 HOFs as a query language
Intro.pdf -- (Spanish, URJC specifics)
To access these notebooks you need first to install git and clone this repository in your local drive:
> git clone https://github.com/jserranohidalgo/urjc-pd.git pd
Then, install jupyter
(see instructions below) and run the program:
jupyter notebook
o jupyter lab
in the root directory of the repository.
Alternatively, you can skip the manual installation of jupyter
and run it through docker as follows:
docker run -it --rm -p 8888:8888 -p 4040:4040 -m 4g -v "$PWD":/home/jovyan/work almondsh/almond:latest
(LINUX)
docker run -it --rm -p 8888:8888 -p 4040:4040 -m 4g -v <<c:/path/to/downloaded/folder>>:/home/jovyan/work almondsh/almond:latest
(WINDOWS)
(also in the root directory of the repository)
Finally, note that jupyter
is already installed in the virtual environment MyApps (just for URJC users).
To install jupyter and run Scala notebooks, follow these steps:
- Install the package manager
conda
, or usepip
, the python package manager. - Install
jupyter
itself - Alternatively, you can also find jupyter notebooks for free when installing anaconda.
- Install Java 8. Take into account whether your architecture is 32-bit or 64-bit.
- Install the Scala plugin
almond
-
On windows, I can't download the installation scripts of the
almond
Scala kernel through:bitsadmin /transfer downloadCoursierCli https://git.io/coursier-cli "Í%%coursier" ...
Likely, you are using powershell; use simple cmd
instead.
Possibly, you will also need to use administration privileges (i.e., run CMD as admin).
- In the thir step (".\coursier launch --fork ..."), the following error pops up:
Exception in thream "main" java.lang.Exception: Unrecognized CPU architecture: x86.
Likely, you need a java version for 64 bits, but you installed one for 32 bits. Check which java version you have by typing: "java -d64 -version".
- Now, the installation command hangs (most likely, on windows)
Execute the installation command with the verbose option enabled (-v -v
):
.\coursier launch --fork almond -M almond.ScalaKernel -v -v -- --install
When the program hangs, stop it (C-c C-c). Most likely, the last command that was attempted was something like "Running java ...". Copy-paste that java invocation and run it manually:
java -Dscala-kernel.version=<...> -jar <...> --install
Luckily, this will complete the installation of the almond kernel.
- "Cannot find default main class. Specify one with -M or --main-class" (most likely, on linux)
Add the option -M almond.ScalaKernel
to the installation command, i.e.
./coursier launch --fork almond -M almond.ScalaKernel -- --install
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.