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
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 |
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
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)) -- расчет и вывод факториала |