-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new Readme, a homewrok exercice and other improvements
- Loading branch information
Showing
18 changed files
with
548 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
Домашно №2 | ||
==== | ||
- **Седмица 1 (19.10.2016)** | ||
[Относно курса](lectures/00-setup/setup.md) | ||
[Що е то функционално програмиране? История на Haskell](lectures/01-intro/intro.md) | ||
[Въведение в Haskell. Основени типове и синтаксис.](lectures/02-syntax-and-types/syntax-and-types.md) | ||
|
||
**ВАЖНО:** Вижте [lists](./exercises/lists/Lists.md) за Домашно №2 | ||
- **Седмица 2 (26.10.2016)** | ||
[Въведение част 2 Lists, Guards and Pattern matching](lectures/03-lists-guards-patterns/lists-guards-patterns.md) | ||
Домашно: [Езика на разбойниците](exercises/secret-lang/Secret-lang.md) ([secret-lang](exercises/secret-lang)) | ||
|
||
- **Седмица 3 (02.11.2016)** | ||
[Работа със списъци](exercises/lists/Lists.md) | ||
Задачи от часа: [Lists.hs](exercises/lists/Lists.hs), [Colorize](exercises/colorize/Colorize.md) ([colorize](exercises/colorize)) | ||
Домашно: [Домашно Lists](exercises/lists/ListsHW.md) ([lists](exercises/lists)) | ||
|
||
- **Седмица 4 (09.11.2016)** | ||
[List comprehension ](lectures/04-list-comprehension/lcomprehension.md) | ||
Задачи от часа: [listcomp.md](exercises/list-comp/listcomp.md) ([list-comp](exercises/list-comp)) | ||
Домашно: [Пермутации](exercises/permutations/perm.md) ([permutations](exercises/permutations)) | ||
|
||
--- | ||
|
||
# fp-haskell | ||
**Допълнителни материали** | ||
[Литература, среда и др.](lectures/00-setup/extra.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{-# OPTIONS_GHC -Wall #-} | ||
module ListComp where | ||
|
||
myLength :: [Int] -> Int | ||
myLength list = sum [ 1 | _ <- list] | ||
|
||
myElem :: Int -> [Int] -> Bool | ||
myElem e list = not (null [x | x <- list, x == e]) | ||
|
||
myElem':: Int -> [Int] -> Bool | ||
myElem' e l = and [True | x <- l, x == e] | ||
|
||
myElem'':: Int -> [Int] -> Bool | ||
myElem'' e l = or [ x == e | x <- l] | ||
|
||
count :: Int -> [Int] -> Int | ||
count e l = myLength [x | x <- l, x == e] | ||
|
||
|
||
arithmeticSeries :: Int -> Int -> Int -> [Int] | ||
arithmeticSeries a incrementator n = [a + x*incrementator | x <- [0..n-1]] | ||
|
||
arithmeticSum :: Int -> Int -> Int -> Int | ||
arithmeticSum a incrementator n = sum (arithmeticSeries a incrementator n) | ||
|
||
geometricSeries :: Double -> Double -> Int -> [Double] | ||
geometricSeries a q n = [a*q^x | x <- [0..n-1]] | ||
|
||
geometricSum :: Double -> Double -> Int -> Double | ||
geometricSum a q n = sum (geometricSeries a q n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# List comprehensions | ||
|
||
- *Трансформацията с функция* на списък рекурсивно: | ||
```hs | ||
f :: [Int] -> [Int] | ||
f [] = [] | ||
f (x:xs) = (някаквa-функция x) : f xs | ||
``` | ||
e равносилна на: | ||
```hs | ||
[някаква функция x | x <- входния-списък] | ||
``` | ||
<br/> | ||
- Филтрацията на списък рекурсивно: | ||
```hs | ||
g :: [Int] -> [Int] | ||
g [] = [] | ||
g (x:xs) | ||
| някакво услове за x = g xs | ||
| otherwise = x : g xs | ||
``` | ||
е равносилна на: | ||
```hs | ||
[ x | x<- входен списък, някакво услове за х] | ||
``` | ||
|
||
|
||
### **[Кодът](listcomp.hs)**, който писахме в клас. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Домашно Lists | ||
===== | ||
|
||
Имплементирайте следните функции: | ||
- [elem](Lists.md#elem) | ||
- [sum](Lists.md#sum) | ||
- [replicate](Lists.md#replicate) | ||
- [interleave](Lists.md#interleave) | ||
|
||
Бонус: всички останли. Започнте с тези за множества - [Списъци като множества](Lists.md#Списъци-като-множества) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Permutations where | ||
|
||
import Data.List hiding (permutations) | ||
|
||
permutations :: [Int] -> [[Int]] | ||
permutations = undefined | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
Пермутации | ||
==== | ||
|
||
## Описание | ||
|
||
Имплементерайте функцията `permutations:: [Int] -> [[Int]]`, която приема списък от числа и връща всички възможни [пермутации](https://www.mathsisfun.com/definitions/permutation.html). | ||
|
||
|
||
## Примерен вход и изход | ||
|
||
```hs | ||
>permutations [1,2,3] | ||
|
||
[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] | ||
``` | ||
## Бонус | ||
Напишете функцията, като използвате най-много 200 символа (и без да сменяте името)! | ||
|
||
### Насока | ||
Броят на всички възможни пермутации на лист с `n` елемента е `n!`. Знаем, че `0! = 1`, какво трябва да връщаме при `permutations []`? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
*page_number:false | ||
--> | ||
|
||
Функционално Програмиране с Haskell | ||
== | ||
Относно курса | ||
==== | ||
|
||
Георги Наков, [nakov.gl at gmail com](mailto:[email protected]) | ||
Марин Маринов, [marinov.ms+ tues at gmail com](mailto:[email protected]) | ||
|
@@ -39,4 +39,4 @@ | |
extra-include-dirs: C:\Program Files\Haskell Platform\7.10.3\mingw\include | ||
``` | ||
|
||
*(не препоръчваме да използвате Windows)* | ||
*(не препоръчваме да използвате Windows)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.