<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://ocw.cs.pub.ro/ppcarte/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://ocw.cs.pub.ro/ppcarte/feed.php">
        <title>books fp</title>
        <description></description>
        <link>https://ocw.cs.pub.ro/ppcarte/</link>
        <image rdf:resource="https://ocw.cs.pub.ro/ppcarte/lib/tpl/bootstrap3/images/favicon.ico" />
       <dc:date>2026-04-24T18:40:13+03:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assig-01&amp;rev=1620311548&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assig-02&amp;rev=1622189131&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assignment-rules&amp;rev=1647427274&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:exam2021-rules&amp;rev=1622119044&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:exam2022&amp;rev=1654009393&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework01&amp;rev=1679467480&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02-draft&amp;rev=1648723130&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02-filteraux&amp;rev=1649684096&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02&amp;rev=1648796013&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework03-draft&amp;rev=1649681758&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework03&amp;rev=1650359297&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework04&amp;rev=1683635242&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab01-java-intro&amp;rev=1615467035&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab01&amp;rev=1645696028&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab02-old&amp;rev=1645693576&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab02&amp;rev=1678436200&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab03&amp;rev=1647610262&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab04&amp;rev=1652648067&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab05&amp;rev=1648706021&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab06&amp;rev=1649411126&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab07&amp;rev=1651587926&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab08&amp;rev=1651069963&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab09&amp;rev=1620916773&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab10&amp;rev=1621506741&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture02&amp;rev=1646741255&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture03&amp;rev=1647599301&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture04&amp;rev=1647943959&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture05&amp;rev=1648545981&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture06&amp;rev=1649153652&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture08&amp;rev=1650359255&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture09&amp;rev=1651823239&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:old-labs&amp;rev=1646849604&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:plagiarism&amp;rev=1614928051&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:rules&amp;rev=1646142353&amp;do=diff"/>
                <rdf:li rdf:resource="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:team&amp;rev=1645523706&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://ocw.cs.pub.ro/ppcarte/lib/tpl/bootstrap3/images/favicon.ico">
        <title>books</title>
        <link>https://ocw.cs.pub.ro/ppcarte/</link>
        <url>https://ocw.cs.pub.ro/ppcarte/lib/tpl/bootstrap3/images/favicon.ico</url>
    </image>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assig-01&amp;rev=1620311548&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-06T17:32:28+03:00</dc:date>
        <title>fp:assig-01</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assig-01&amp;rev=1620311548&amp;do=diff</link>
        <description>Deadline: May 7th, 23:55

Introduction

For this assignment, we will work with images and implement some basic image manipulations.
We will work with two types of images: greyscale and RGB.

Image representation

Internally, images are modeled as two-dimensional matrices of pixels; in Haskell we will model this by using lists of lists.</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assig-02&amp;rev=1622189131&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-28T11:05:31+03:00</dc:date>
        <title>fp:assig-02</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assig-02&amp;rev=1622189131&amp;do=diff</link>
        <description>Deadline: May 31th, 23:55

Introduction

Similar to the first assignment, we will perform some image manipulations. You do not need to have worked on the first assignment in order to work on this one, but you should read its statement to understand the basic ideas behind the image formats used.$ f = \frac{259\cdot(c + 255)}{255\cdot(259 - c)}$$ f\cdot(oldValue - 128) + 128$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assignment-rules&amp;rev=1647427274&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-16T12:41:14+03:00</dc:date>
        <title>fp:assignment-rules</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:assignment-rules&amp;rev=1647427274&amp;do=diff</link>
        <description>Submission guidelines

Project format

	*  You should not change any other files of the project, except for the template-file. For this homework, the template-file is FSets.scala. Warning: if a submission has changes in other files, it may not be graded</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:exam2021-rules&amp;rev=1622119044&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-27T15:37:24+03:00</dc:date>
        <title>fp:exam2021-rules</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:exam2021-rules&amp;rev=1622119044&amp;do=diff</link>
        <description>FP Exam (june 2021)

The exam will take place online (via MS Teams) and it will consist of four questions:

	*  (Q1) a simple Haskell programming task - 2 points
	*  (Q2) a list processing task in Haskell - 2 points
	*  (Q3) an algebraic datatype task -</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:exam2022&amp;rev=1654009393&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-05-31T18:03:13+03:00</dc:date>
        <title>fp:exam2022</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:exam2022&amp;rev=1654009393&amp;do=diff</link>
        <description>Exam FP 2022

	*  The exam will take place on the 9th of June, at 14:00, in room Pr001 from the Precis building.
	*  It is advisable that you should be present with at least 10 minutes in advance.

	*  Having a laptop is a prerequisite for taking the exam.</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework01&amp;rev=1679467480&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-03-22T08:44:40+03:00</dc:date>
        <title>fp:homework01</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework01&amp;rev=1679467480&amp;do=diff</link>
        <description>Homework 1. Sets as functions

Problem statement

Sets are unordered collections of unique elements. There are several ways to store sets. One of them relies on characteristic functions. Such functional sets are especially useful if we expect many insert/retrieve$ A \subseteq U$$ f: U \rightarrow \{0,1\}$$ f(x) = 1$$ x \in A$$ f(x) = 0$$ x \not\in A$$ U$$ \{1,2,3\}$$ \{start, start+1, \ldots, stop\}$$  \exists x. P(X) \iff \lnot \forall x.\lnot P(X)$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02-draft&amp;rev=1648723130&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-31T13:38:50+03:00</dc:date>
        <title>fp:homework02-draft</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02-draft&amp;rev=1648723130&amp;do=diff</link>
        <description>H02. Tree Sets

Problem statement

In this homework, you will implement a binary search tree, that you will use to gather stats about words from a particular text. Generally, in a  binary search tree:

	*  each non-empty node contains exactly one value and two children$ f \circ g$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02-filteraux&amp;rev=1649684096&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-11T16:34:56+03:00</dc:date>
        <title>fp:homework02-filteraux</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02-filteraux&amp;rev=1649684096&amp;do=diff</link>
        <description>Suppose pred = x =&gt; x % 3 == 0
We abstract away the predicate, to make the example clearer.

      3
    /   \
   1     5       .filterAux(  Empty  )
    \   /  \
     2 4    6
     
     
     5                          1
   /   \         .filterAux(     \   .filterAux(Empty))
  4     6                         2

    
     5                                
   /   \         .filterAux(Empty.filterAux((2.filterAux(Empty)).ins(1)))
  4     6                               

     5                  …</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02&amp;rev=1648796013&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-01T09:53:33+03:00</dc:date>
        <title>fp:homework02</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework02&amp;rev=1648796013&amp;do=diff</link>
        <description>H02. Tree Sets

Problem statement

In this homework, you will implement a binary search tree, that you will use to gather stats about words from a particular text. Generally, in a  binary search tree:

	*  each non-empty node contains exactly one value and two children$ f \circ g$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework03-draft&amp;rev=1649681758&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-11T15:55:58+03:00</dc:date>
        <title>fp:homework03-draft</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework03-draft&amp;rev=1649681758&amp;do=diff</link>
        <description>Homework 3 - Tic Tac Toe

In this homework, you will implement some functionality which will allow you to design a completely functional tic-tac-toe AI. The latter will be part of homework 4.

About Tic Tac Toe

Tic Tac Toe is usually played on a 3 by 3 board, marking positions by each player in rounds. Our game is slightly different:</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework03&amp;rev=1650359297&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-19T12:08:17+03:00</dc:date>
        <title>fp:homework03</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework03&amp;rev=1650359297&amp;do=diff</link>
        <description>Homework 3 - Tic Tac Toe

In this homework, you will implement some functionality which will allow you to design a completely functional tic-tac-toe AI. The latter will be part of homework 4.

About Tic Tac Toe

Tic Tac Toe is usually played on a 3 by 3 board, marking positions by each player in rounds. Our game is slightly different:</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework04&amp;rev=1683635242&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-05-09T15:27:22+03:00</dc:date>
        <title>fp:homework04</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:homework04&amp;rev=1683635242&amp;do=diff</link>
        <description>Homework 4. Five in a row AI

Homework 4 consists in developing a complete five-in-a-row game, together with an AI and a very basic interface. 

	*  For this stage, you will decide on the structure of your project, as well as write tests to guide your implementation.</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab01-java-intro&amp;rev=1615467035&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-03-11T14:50:35+03:00</dc:date>
        <title>fp:lab01-java-intro</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab01-java-intro&amp;rev=1615467035&amp;do=diff</link>
        <description>Introduction to Functional Programming (in Java!)

1. A single function to implement all of them

1.1. Write a method that takes a list of integers and returns a new list with all elements multiplied by two.

1.2. Write a method that takes a list of $ f : A \rightarrow B$$ A$$ B$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab01&amp;rev=1645696028&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-02-24T11:47:08+03:00</dc:date>
        <title>fp:lab01</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab01&amp;rev=1645696028&amp;do=diff</link>
        <description>Introduction to Scala

Scala setup

Installation

Scala can be downloaded and installed on either a Windows or NIX platform (e.g. Linux, OS-X) here. For this lecture you must install Scala 3, and we recommend installing it using Coursier (see the previous link)</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab02-old&amp;rev=1645693576&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-02-24T11:06:16+03:00</dc:date>
        <title>fp:lab02-old</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab02-old&amp;rev=1645693576&amp;do=diff</link>
        <description>2. Introduction to Haskell

2.1. Functions in Haskell

In mathematics, functions have a domain an codomain. In Haskell, functions have types or signatures. They often can be omitted in Haskell, but can
also be explicitly written as in:


f :: Integer -&gt; Integer -&gt; Integer
f x y = x + y

$ e_1$$ e_2$$ e_1$$ e_2$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab02&amp;rev=1678436200&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-03-10T10:16:40+03:00</dc:date>
        <title>fp:lab02</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab02&amp;rev=1678436200&amp;do=diff</link>
        <description>2. Scala syntax and function definition

 Objectives: 

	*  get yourself familiar with Scala syntax basics
	*  practice writing tail-recursive functions as an alternative to imperative loops 
	*  keep your code clean and well-structured.

 Create a new Scala worksheet to write your solutions $ n$$ 1 + 2^2 + 3^2 + \ldots + (n-1)^2 + n^2$$ \sqrt{a}$$ x_0 = 1$$ x_{n+1} = \displaystyle\frac{1}{2}(x_n+\frac{a}{x_n})$$ x_n$$ \sqrt{a}$$ x_{n+1}$$ x_0 = 1$$ x_n$$ \sqrt{a}$$ a$$ n$$ (x_n)_n$$ \sqrt{a}$$ …</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab03&amp;rev=1647610262&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-18T15:31:02+03:00</dc:date>
        <title>fp:lab03</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab03&amp;rev=1647610262&amp;do=diff</link>
        <description>3. Higher-order functions

Objectives:

	*  implement and use higher-order functions. A higher-order function takes other functions as parameter or returns them
	*  implement curry and uncurry functions, and how they should be properly used (review lecture).$ count_k(n) = k + 2k + 3k + \ldots x*k$$  x*k \leq n$$ k$$ count_1(n) + count_2(n) + \ldots + count_k(n)$$ a_1, a_2, \ldots, a_k$$ f(a_1)\;op\;f(a_2)\;op\;\ldots f(a_k)$$ 1 + 2^2 + 3^2 + \ldots + (n-1)^2 + n^2$$ (f(a) + f(b))(b-a)/2$</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab04&amp;rev=1652648067&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-05-15T23:54:27+03:00</dc:date>
        <title>fp:lab04</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab04&amp;rev=1652648067&amp;do=diff</link>
        <description>4. Lists in Scala

Objectives:

	*  get familiar with pattern matching lists, as well as common list operations from Scala and how they work
	*  get familiar with common higher-order functions over lists (partition, map, foldRight, foldLeft, filter)</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab05&amp;rev=1648706021&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-31T08:53:41+03:00</dc:date>
        <title>fp:lab05</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab05&amp;rev=1648706021&amp;do=diff</link>
        <description>5. Functional data representation

5.1. Nats

Consider the following toy implementation of the type Nat which encodes natural numbers.


trait Nat {}
case object Zero extends Nat {}
case class Succ(n: Nat) extends Nat {}


For instance, 3 will be encoded as the value:</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab06&amp;rev=1649411126&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-08T12:45:26+03:00</dc:date>
        <title>fp:lab06</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab06&amp;rev=1649411126&amp;do=diff</link>
        <description>Lab 06. Polymorphism in Scala

This lab will start with the implementations discussed during lecture. Please find the polymorphic trait FList[A] below:


trait FList[A]{ // list with elements of type A
  def length: Int
  def head: A
  def tail: FList[A]
  def map[B](f: A =&gt; B): FList[B]
  // a op (b op (c op acc))
  def foldRight[B](acc: B)(op: (A,B) =&gt; B): B
  // ((acc op a) op b) op c
  def foldLeft[B](acc: B)(op: (B,A) =&gt; B): B
  
  def contains(e: A):Boolean =
    this.foldRight(false)(_ ==…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab07&amp;rev=1651587926&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-05-03T17:25:26+03:00</dc:date>
        <title>fp:lab07</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab07&amp;rev=1651587926&amp;do=diff</link>
        <description>L07. For expressions

In this lab, we will use matrices to encode Bitmap images. The format is called BPM, and more details are available here. Our format will be grayscale only. Each pixel of the matrix is encoded as an integer, with values from 0 to 255. Some examples are shown below:</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab08&amp;rev=1651069963&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-27T17:32:43+03:00</dc:date>
        <title>fp:lab08</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab08&amp;rev=1651069963&amp;do=diff</link>
        <description>L08. Maps in Scala

8.1. Gradebooks as maps

We represent a gradebook as a map which holds, for each student (encoded as String), its grade (an Int). We implement a gradebook as a case class, as follows:


case class Gradebook(book: Map[String,Int])</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab09&amp;rev=1620916773&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-13T17:39:33+03:00</dc:date>
        <title>fp:lab09</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab09&amp;rev=1620916773&amp;do=diff</link>
        <description>9. Algebraic data-types (ADT)

A simple definition of an ADT in Haskell is:


data Shape = Rectangle Integer Integer | Circle Integer


The part data Shape = ... of a definition introduces a new type called Shape in the program. Objects of any type (including</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab10&amp;rev=1621506741&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-05-20T13:32:21+03:00</dc:date>
        <title>fp:lab10</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lab10&amp;rev=1621506741&amp;do=diff</link>
        <description>10. Trees

File systems are one common application that uses a tree representation. We define the following data type to model a very simplistic file system:


data FTree = Dir String [FTree] | File String deriving (Show, Eq)

deriving (Show, Eq)Show</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture02&amp;rev=1646741255&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-08T14:07:35+03:00</dc:date>
        <title>fp:lecture02</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture02&amp;rev=1646741255&amp;do=diff</link>
        <description>Introduction to Scala syntax

A few basic examples


def myAddition(x: Int, y: Int): Int = x + y
myAddition(1,2)

def inRange(start: Int, stop: Int, x: Int): Boolean =
  if (x &lt;= stop &amp;&amp; x &gt;= start) true
  else false
  
def inRange1(start: Int, stop: Int, x: Int): Boolean =
  x &lt;= stop &amp;&amp; x &gt;= start

def and(x: Boolean, y: Boolean): Boolean =
  if (x) y else false
and(false, true)
false &amp;&amp; true</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture03&amp;rev=1647599301&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-18T12:28:21+03:00</dc:date>
        <title>fp:lecture03</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture03&amp;rev=1647599301&amp;do=diff</link>
        <description>L03. Higher-order functions

Functions that take other functions as parameter


def sumWithf (f: Int =&gt; Int, start: Int, stop:Int): Int = {
  def aux(i: Int, acc: Int): Int =
    if (i&gt;stop) acc
    else aux(i+1, f(i) + acc)
  aux(start,0)
}
sumWithf(x =&gt; x, 0, 10)</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture04&amp;rev=1647943959&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-22T12:12:39+03:00</dc:date>
        <title>fp:lecture04</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture04&amp;rev=1647943959&amp;do=diff</link>
        <description>L04. Lists and their higher-order functions


/* how to construct lists */
val l0 = List(1,2,3) // the list [1,2,3]   has type List[Int]
List(&quot;apples&quot;,&quot;banannas&quot;) // List[String]
List('c','h','a','r') // List[Char]

List(Nil, List(3,4), List(5,6)) // List[List[Int]]

/*
*   Lists are: homogeneous - THEY CONTAIN ELEMENTS OF THE
*   same type
*
 */

/* how to construct lists (using cons, and Nil)*/

(1 :: (2 :: (3 :: Nil))).head //just the same as List(1,2,3)

/*
  e :: l
  ^ current element
     …</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture05&amp;rev=1648545981&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-29T12:26:21+03:00</dc:date>
        <title>fp:lecture05</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture05&amp;rev=1648545981&amp;do=diff</link>
        <description>5. Functional data representation in Scala


/*
  (Functional) Data representation in Scala


A few syntax basics:

 */

// we define a class (called Point)
// we define the constructor for the class:
// Point(1,2)
class Point(x: Int, y: Int){

  def xVal:Int  = x
  def yVal:Int = y
  // checks if a point is higher on the y axis than our current point
 // higher is method of the class Point
  def higher(p: Point): Boolean =
   p.yVal &gt; y

  override def toString : String =
    s&quot;({},{})&quot;
}


val…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture06&amp;rev=1649153652&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-05T13:14:12+03:00</dc:date>
        <title>fp:lecture06</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture06&amp;rev=1649153652&amp;do=diff</link>
        <description>L06. Polymorphism


/*
   (A) Subtype polymorphism:

   A type S is related to another type T (supertype) by some notion
   of substitutability, meaning that functions written to operate on elements
   of type T(supertype) can also operate on elements of type S (subtype)

   Example:
 */

class Animal {
  def scream: String = &quot;An animal screams!&quot;
}

class Wolf extends Animal {
  override def scream: String = &quot;A wolf screams&quot;
}

new Animal().scream

/*
 (B) Ad-hoc polymorphism

     Is obtained w…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture08&amp;rev=1650359255&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-04-19T12:07:35+03:00</dc:date>
        <title>fp:lecture08</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture08&amp;rev=1650359255&amp;do=diff</link>
        <description>L08. For expressions

A few motivational examples for using for expressions:


val l = List(&quot;this&quot;, &quot;is&quot;, &quot;a&quot;, &quot;list&quot;, &quot;of&quot;, &quot;strings&quot;)

l.map(_.length)

l.map(_.length).filter(_ &gt; 2)

// suppose we have another list of strings:

val l1 = List(&quot;is&quot;, &quot;s&quot;, &quot;th&quot;, &quot;list&quot;, &quot;str&quot;, &quot;ings&quot;, &quot;i&quot;, &quot;t&quot;, &quot;&quot;)

// suppose we have a dictionary (words which make sense in English)
val dictionary = l

/*
  We want to find ALL PAIRS of words from l1, which
  are valid English words
 */

// We start by constructing…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture09&amp;rev=1651823239&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-05-06T10:47:19+03:00</dc:date>
        <title>fp:lecture09</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:lecture09&amp;rev=1651823239&amp;do=diff</link>
        <description>L09. Scala collections


val letters = Vector(&quot;v&quot;, &quot;m&quot;, &quot;n&quot;, &quot;i&quot;)

/* the colon operator, allways indicates &quot;associativity&quot;
*   collection :@ element
*
*   element #: collection
*
*  */
letters :+ &quot;z&quot;
&quot;a&quot; +: letters


/* Ranges
*  (Int, Int) =&gt; Range
*  _.to(_)
*
*  (Int, Int) =&gt; Range
*  _.until(_)
*
*  (Range, Int) =&gt; Range
*  _.by(_)
*
*
* */
1.to(5)
1 to 5

1.until(5)

1 until 5

1 to 5 by 2

/* shorthand
a b c
for:
a.b(c)
 */

/*
 In Scala you can define functions that are not named only wi…</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:old-labs&amp;rev=1646849604&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-09T20:13:24+03:00</dc:date>
        <title>fp:old-labs</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:old-labs&amp;rev=1646849604&amp;do=diff</link>
        <description>4. Higher order functions

4.1. Map, foldl, foldr, filter, zipWith

Map

The function map has signature: (a-&gt;b) -&gt; [a] -&gt; [b]. It takes as parameter:

	*  a transformer function f :: a-&gt;b
	*  a list of objects of type a

It returns:

	*  a list of transformed objects of type</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:plagiarism&amp;rev=1614928051&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2021-03-05T09:07:31+03:00</dc:date>
        <title>fp:plagiarism</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:plagiarism&amp;rev=1614928051&amp;do=diff</link>
        <description>Plagiarism and academic integrity

Acording to UPB rules for diploma studies (article 51. points d. and i.), students are required to uphold the rules for academic integrity described in The UPB charter. Of these we explicitly mention article 45, point 13) a. which states that plagiarism is a severe misconduct</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:rules&amp;rev=1646142353&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-03-01T15:45:53+03:00</dc:date>
        <title>fp:rules</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:rules&amp;rev=1646142353&amp;do=diff</link>
        <description>Rules

Points

	*  Semester: 5.5p
	*  Exam: 5p 
	*  For exam admission, a minimum of:
		*  2.5p semester points are required
		*  1.5p homework points are required

	*  a minimum of 2.5p are required to pass the exam

Semester points

	*  Lab: 1p (lab attendance)</description>
    </item>
    <item rdf:about="https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:team&amp;rev=1645523706&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2022-02-22T11:55:06+03:00</dc:date>
        <title>fp:team</title>
        <link>https://ocw.cs.pub.ro/ppcarte/doku.php?id=fp:team&amp;rev=1645523706&amp;do=diff</link>
        <description>Functional Programming 2021

Team members

	*  Matei Popovici



Lecture

	*  weekly: Fridays 10:00-12:00  MS Teams

Labs

	*  1231A: Fridays 12:00-14:00  MS Teams
	*  1231B: Thursdays 16:00-18:00  MS Teams</description>
    </item>
</rdf:RDF>
