This repository has been archived on 2025-07-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fp/test0/Types.hs
AKP 4452a7b30f
Add practise test (test0)
Squashed commit of the following:

commit cec03384fa88ae8f74adee81491ea40865aa2f3f
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 13:42:15 2023 +0100

    Question 5

commit 11aa1f2e3b4ed9410c88c5fc19a23963e4f4722e
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 13:21:41 2023 +0100

    Question 4

commit e6aaadb45869c3d5cc57a69bcc0862be883834e8
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 13:13:04 2023 +0100

    Question 3.2

commit f74fd8d782a283596bdbca21d28b2522b9ff29fc
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 12:29:41 2023 +0100

    Question 3.1

commit d3e03478ba3a54bada957c5b3ec45cbd0ee8e5d9
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 12:23:53 2023 +0100

    Question two

commit 6f9d44a0a3439abf12010eab9bb06a9a93dcb943
Author: AKP <abi@tdpain.net>
Date:   Thu Oct 26 12:11:59 2023 +0100

    Question 1
2023-10-26 14:06:25 +01:00

59 lines
1.8 KiB
Haskell

-- setting the "warn-incomplete-patterns" flag asks GHC to warn you
-- about possible missing cases in pattern-matching definitions
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
{-# LANGUAGE FlexibleInstances #-}
-- see https://wiki.haskell.org/Safe_Haskell
{-# LANGUAGE Safe #-}
---------------------------------------------------------------------------------
-------------------------- DO **NOT** MODIFY THIS FILE --------------------------
---------------------------------------------------------------------------------
module Types (module Types, module Data.Char) where
import Data.Char
import Control.Concurrent
import Data.Int
import Data.Maybe
-- Types for real test
charLabel :: Char -> Int
charLabel char = ord (toUpper char) - ord 'A'
key1 :: String
key1 = "LYKBDOCAWITNVRHJXPUMZSGEQF"
key2 :: String
key2 = "UDMZIQKLNJOSVETCYPBXAWRGHF"
plaintext1 :: String
plaintext1 = "The Quick Brown Fox Jumped Over The Lazy Dog"
plaintext2 :: String
plaintext2 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
factors :: Int -> [Int]
factors n = [ k | k <- [1..n] , n `mod` k == 0 ]
isPrime :: Int -> Bool
isPrime n = factors n == [1, n]
-- Question 4
type Direction = Int
type Command = (Direction, Int)
exampleCommands :: [Command]
exampleCommands = [(1, 10), (0, 5), (2, 20)]
-- Question 5
neg :: Int8 -> Int8
neg n = -n
doubleNeg :: Int8 -> Int8
doubleNeg n = - (- n)