Skip to content

Instantly share code, notes, and snippets.

View AlexTsyganov's full-sized avatar

Alex Tsyganov AlexTsyganov

View GitHub Profile
@AlexTsyganov
AlexTsyganov / FP; Lab 2.hs
Created January 22, 2016 08:06
Courses of functional programming 2015
module Lab2 where
data BinaryTree = Empty | Node BinaryTree Integer BinaryTree
emptyTree :: BinaryTree-- создание пустого дерева
emptyTree = Empty
insert :: BinaryTree -> Integer -> BinaryTree -- добавления элемента
insert (Empty) a = Node Empty a Empty
@AlexTsyganov
AlexTsyganov / FP; Lab 1.hs
Created January 22, 2016 08:02
Courses of functional programming 2015
factorial n = if n == 0 then 1 else n * factorial (n - 1) -- рекурсивная функция факториала
main = do
putStrLn "Enter number:" -- выведет "Enter number:"
inpStr <- getLine -- получить значения
let x = (read inpStr)::Integer -- чар в инт
putStrLn ("Factorial:" ++ show (factorial x)) -- расчет и вывод факториала