This file contains hidden or 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 AST where | |
newtype Prog a b = Prog [Fun a b] | |
newtype Fun a b = Fun (a, [b], Exp a b) | |
data BoolExp a b = Lt (Exp a b) (Exp a b) | |
| Gt (Exp a b) (Exp a b) | |
| Eq (Exp a b) (Exp a b) | |
| AND (BoolExp a b) (BoolExp a b) |
This file contains hidden or 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
\section*{Question 3: Sources of Randomness (10 points)} | |
\begin{enumerate} | |
\item a stream of sequential numbers starting from a truly random value. | |
This is can be considered as true randomness. Since the given stream generates sequential numbers, an attacker has no way of predicting the sequence and especially the starting initial value of the sequence. | |
\item a stream of the SHA-256 hash of sequential numbers starting from a truly random value. | |
If a hash is discovered it won't be possible to guess the sequence of numbers and reverse the hash, since the starting number of underlying sequence is truly random. Given that the sequence is hashed using SHA-256, this can be considered a crypto-suitable pseudo pseudo randomness. It uses the truly random number as a seed. | |
This file contains hidden or 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
./build/bin/scanner -f test/data/legit-token-salad.t3 | |
[ | |
{ | |
"line": 3, | |
"token": "+", | |
"value": "+" | |
}, | |
{ | |
"line": 4, | |
"token": "-", |
This file contains hidden or 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
./build/bin/scanner tests/ms1/legit-token-salad.t3 | |
[ | |
{ | |
"line": 1, | |
"token": ">=", | |
"value": "(null)" | |
}, | |
{ | |
"line": 3, | |
"token": "+", |
This file contains hidden or 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
-- use: buildCycle [1..5] [2, 4, 5, 1, 3] [] | |
-- output: [[3,5],[5,3],[1,2,4]] | |
buildCycle :: (Eq a) => [a] -> [a] -> [a] -> [[a]] | |
buildCycle [] [] initial = [initial] | |
buildCycle (a : as) (b : bs) initial | |
| null initial = buildCycle as bs [a, b] | |
| otherwise = if (a `notElem` initial) && (b `notElem` initial) | |
then [a, b] : buildCycle as bs initial | |
else if a `notElem` initial |
This file contains hidden or 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
group :: (a -> a -> Bool) -> [a] -> [[a]] | |
group _ [] = [] | |
group _ [el] = [[el]] | |
group predicate (a : b : list) | |
| predicate a b = append a (group predicate (b : list)) | |
| otherwise = [a] : group predicate (b : list) | |
where append el (a : list) = (el : a) : list | |
nbr :: Int -> Int -> Bool | |
nbr num1 num2 = abs (num1 - num2) <= 1 |
This file contains hidden or 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
-- 4. Write a function to determine whether its first argument, a list of integers, is lexicographically larger than its second argument: lexInt::[Int] -> [Int] -> Bool. | |
lexInt :: [Int] -> [Int] -> Bool | |
lexInt [] [] = True | |
lexInt list [] = False | |
lexInt [] list = True | |
lexInt list1 list2 = concatMap show list1 >= concatMap show list2 | |
-- Recursive solution | |
-- lexInt (el1 : list1) (el2 : list2) | show el1 >= show el2 = lexInt list1 list2 | |
-- | otherwise = False |
This file contains hidden or 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
data Rose a = Rs [(a, Rose a)] | |
foldRose :: ([(a, c)] -> c) -> Rose a -> c | |
foldRose g (Rs vals) = g (map (\(a, arg) -> (a, foldRose g arg)) vals) | |
mapRose :: (a -> b) -> (Rose a) -> b | |
mapRose func (Rs vals) = Rs (map (\(a, rose) -> (func a, mapRose func rose)) vals) | |
heightRose :: Rose a -> Int | |
-- what is `xs`?? |
This file contains hidden or 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
shake > configure | |
shake > Configuring shake-0.18.3... | |
shake > build | |
shake > Preprocessing library for shake-0.18.3.. | |
shake > Building library for shake-0.18.3.. | |
shake > [ 1 of 73] Compiling Development.Ninja.Env | |
shake > [ 2 of 73] Compiling Development.Ninja.Type | |
shake > [ 3 of 73] Compiling Development.Ninja.Lexer | |
shake > [ 4 of 73] Compiling Development.Ninja.Parse | |
shake > [ 5 of 73] Compiling Development.Shake.Classes |
This file contains hidden or 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
package reflection; | |
import java.lang.reflect.*; | |
import java.lang.Class; | |
import java.lang.Object; | |
import data.*; | |
import java.io.PrintStream; | |
import static java.lang.System.out; | |
/** | |
* Do the following using reflection (inside the `main`) |