-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
2,813 additions
and
1,002 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 |
---|---|---|
|
@@ -15,5 +15,5 @@ | |
{ | ||
Construct the new line and then print it. | ||
} | ||
end; | ||
end | ||
end. |
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 @@ | ||
val it = () : unit | ||
val it = fn : 'a -> 'b -> ('a * 'b -> 'b) -> 'b | ||
val it = fn : int * real -> (real -> string) -> bool | ||
val it = fn : ('a -> 'b -> 'c) -> 'a -> 'b -> 'd -> 'c | ||
val it = fn : 'a -> 'b -> int -> int -> int | ||
val it = fn : ('a -> 'b) -> 'a -> ('b * 'b -> 'c) -> 'c | ||
val it = fn : unit -> unit -> int | ||
val it = fn : 'a -> 'a * 'a -> 'a | ||
val it = fn : int * string * string -> int * string * string | ||
- |
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,9 @@ | ||
print "===TEST START===\n"; | ||
sig1; | ||
sig2; | ||
sig3; | ||
sig4; | ||
sig5; | ||
sig6; | ||
sig7; | ||
sig8; |
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,6 @@ | ||
val it = () : unit | ||
val it = fn : int -> int -> int | ||
val test_1 = "Passed" : string | ||
val it = fn : int * int -> int | ||
val test_2 = "Passed" : string | ||
- |
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,5 @@ | ||
print "===TEST START===\n"; | ||
curry op*; | ||
val test_1 = if 12 = it 3 4 then "Passed" else "Failed"; | ||
uncurry it; | ||
val test_2 = if 12 = it (3,4) then "Passed" else "Failed"; |
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,4 @@ | ||
val it = () : unit | ||
val test_1 = "Passed" : string | ||
val test_2 = "Passed" : string | ||
- |
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,3 @@ | ||
print "===TEST START===\n"; | ||
val test_1 = if alive = is_alive (alive, empty, empty) (empty, alive, alive) (empty, empty, empty) then "Passed" else "Failed"; | ||
val test_2 = if empty = is_alive (alive, alive, alive) (empty, alive, empty) (alive, alive, alive) then "Passed" else "Failed"; |
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 @@ | ||
fun toChar false = #" " | toChar true = #"*" |
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,13 @@ | ||
signature KERNEL1D_SIG = sig | ||
type source | ||
type target | ||
val kernel : source -> source -> source -> target | ||
val default : source -> source | ||
end; | ||
|
||
signature KERNEL2D_SIG = sig | ||
type source | ||
type target | ||
val kernel : source * source * source -> source * source * source -> source * source * source -> target | ||
val default : source -> source | ||
end; |
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,9 @@ | ||
val it = () : unit | ||
val test1 = "PASSED" : string | ||
val test2 = "PASSED" : string | ||
val test3 = "PASSED" : string | ||
val test4 = "PASSED" : string | ||
* | ||
* * | ||
val test5 = () : unit | ||
|
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,6 @@ | ||
print "===TEST START===\n"; | ||
val test1 = if (mapState (fn true => 1 | false => 0) [[false, true, false], [true, false, true]]) = [[0, 1, 0], [1, 0, 1]] then "PASSED" else "FAILED"; | ||
val test2 = if (toString (explode "Hello world")) = "Hello world" then "PASSED" else "FAILED"; | ||
val test3 = if (frameToState [" * ", "* *"]) = [[false, true, false], [true, false, true]] then "PASSED" else "FAILED"; | ||
val test4 = if (stateToFrame [[false, true, false], [true, false, true]]) = [" * ", "* *"]then "PASSED" else "FAILED"; | ||
val test5 = printFrame [" * ", "* *"]; |
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,6 @@ | ||
val it = () : unit | ||
val test1 = "PASSED" : string | ||
val test2 = "PASSED" : string | ||
val test3 = "PASSED" : string | ||
val test4 = "PASSED" : string | ||
|
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,20 @@ | ||
fun sum a b c = a + b + c; | ||
|
||
structure SumKernel1D = Kernel1D(struct | ||
type source = int | ||
type target = int | ||
val kernel = sum | ||
fun default _ = 0 | ||
end); | ||
structure SumKernel2D = Kernel2D(struct | ||
type source = int | ||
type target = int | ||
fun kernel (x1, x2, x3) (y1, y2, y3) (z1, z2, z3) = 2 * x2 + y2 + 3 * z2 | ||
fun default _ = 0 | ||
end); | ||
|
||
print "===TEST START===\n"; | ||
val test1 = if (SumKernel1D.runKernel [1, 2, 3, 4]) = [3, 6, 9, 7] then "PASSED" else "FAILED"; | ||
val test2 = if (zip [1, 2, 3] [4, 5, 6] [7, 8, 9]) = [(1, 4, 7), (2, 5, 8), (3, 6, 9)] then "PASSED" else "FAILED"; | ||
val test3 = if (fill false 3) = [false, false, false] then "PASSED" else "FAILED"; | ||
val test4 = if (SumKernel2D.runKernel [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) = [[7, 13, 7], [19, 31, 16], [31, 49, 25]] then "PASSED" else "FAILED"; |
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,69 @@ | ||
#!/bin/bash | ||
|
||
testsurl="https://raw.githubusercontent.com/AdiHarif/236319-Spr-2023/master/HW/Homework3/" | ||
|
||
tmpdir="selfcheck_tmp" | ||
test_files=("q1" "q2") | ||
required_files=("hw3_q1.sml" "hw3_q2.sml" "dry.pdf") | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: ./"$( basename "$0" )" <your submission zip file>" | ||
exit | ||
fi | ||
|
||
if [ ! -f "$1" ]; then | ||
echo "Submission zip file not found!" | ||
exit | ||
fi | ||
|
||
rm -rf "$tmpdir" &> /dev/null | ||
if [ -d "$tmpdir" ] | ||
then | ||
echo "Cannot clear tmp directory. Please delete '$tmpdir' manually and try again" | ||
exit | ||
fi | ||
mkdir "$tmpdir" &> /dev/null | ||
|
||
yes | apt install zip &> /dev/null | ||
|
||
unzip "$1" -d "$tmpdir" &> /dev/null | ||
if [[ $? != 0 ]]; then | ||
echo "Unable to unzip submission file!" | ||
exit | ||
fi | ||
|
||
cd "$tmpdir" | ||
for f in "${required_files[@]}" | ||
do | ||
if [ ! -f $f ]; then | ||
echo "File $f not found!" | ||
exit | ||
fi | ||
done | ||
|
||
if [ $( ls | wc -l ) != ${#required_files[@]} ]; then | ||
echo "There are too many files in the submission" | ||
exit | ||
fi | ||
|
||
for test in "${test_files[@]}" | ||
do | ||
wget "$testsurl$test.in" "$testsurl$test.expected" "${testsurl}hw3_${test}_def.sml" &> /dev/null | ||
if [ ! -f "$test.in" ] || [ ! -f "$test.expected" ] || [ ! -f "hw3_${test}_def.sml" ]; then | ||
echo "Unable to download test $test!" | ||
exit | ||
fi | ||
sml hw3_$test.sml < $test.in &> $test.rawout | ||
sed '1,/===TEST START===/d' $test.rawout > $test.out | ||
diff $test.out $test.expected | ||
if [[ $? != 0 ]]; then | ||
echo "Failed test $test!" | ||
exit | ||
fi | ||
done | ||
|
||
cd - &> /dev/null | ||
rm -rf "$tmpdir" | ||
|
||
echo "Ok to submit :)" | ||
exit |
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,51 @@ | ||
use "hw2_q3.sml"; | ||
use "hw3_q1.sml"; | ||
use "hw3_q2.sml"; | ||
|
||
local | ||
fun toCell false = empty | ||
| toCell true = alive; | ||
in | ||
fun is_alive_bool (x1, x2, x3) (y1, y2, y3) (z1, z2, z3) = | ||
case ( | ||
is_alive | ||
(toCell x1, toCell x2, toCell x3) | ||
(toCell y1, toCell y2, toCell y3) | ||
(toCell z1, toCell z2, toCell z3)) of empty => false | alive => true | ||
end; | ||
|
||
fun run f 0 _ = () | ||
| run f times delay = (f(); OS.Process.system ("sleep " ^ Real.toString delay); run f (times - 1) delay); | ||
|
||
val start_frame = [ | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" *** *** *** *** * *** ", | ||
" * * * * ** * * ", | ||
" *** *** *** *** * *** ", | ||
" * * * * * * * ", | ||
" *** *** *** *** *** *** ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" ", | ||
" "]; |
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,5 @@ | ||
datatype 'a tree = | ||
Nil | ||
| Br of 'a * ('a tree) * ('a tree); | ||
|
||
datatype ('a, 'b) union = type1 of 'a | type2 of 'b; |
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,12 @@ | ||
datatype 'a seq = Nil | Cons of 'a * (unit -> 'a seq); | ||
|
||
fun counter () = let | ||
val count = ref 0; | ||
fun aux n () = Cons (n + 1, ( | ||
count := 1 + !count; | ||
print ("exec: " ^ Int.toString (!count) ^ "\n"); | ||
aux (n + 1) | ||
)) | ||
in | ||
(Cons(0, aux 0)) | ||
end; |
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,16 @@ | ||
val it = () : unit | ||
val test1 = "PASSED" : string | ||
val game = fn : unit -> unit | ||
*** | ||
* * | ||
*** | ||
val it = () : unit | ||
* * | ||
* * | ||
* * | ||
val it = () : unit | ||
|
||
** ** | ||
|
||
val it = () : unit | ||
|
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,6 @@ | ||
print "===TEST START===\n"; | ||
val test1 = if (runCycle [" *** ", " * * ", " *** "]) = [" * * ","* *"," * * "] then "PASSED" else "FAILED"; | ||
val game = gameOfLife [" *** ", " * * ", " *** "]; | ||
game(); | ||
game(); | ||
game(); |
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,4 @@ | ||
val it = () : unit | ||
val it = [0,1,2] : int list | ||
val it = Br (0,Br (2,Nil,Nil),Br (4,Nil,Nil)) : int tree | ||
|
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,3 @@ | ||
print "===TEST START===\n"; | ||
flatten (Br(0, Br(1, Nil, Nil), Br(2, Nil, Nil))); | ||
map (fn x => 2 * x) (Br(0, Br(1, Nil, Nil), Br(2, Nil, Nil))); |
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 @@ | ||
val it = () : unit | ||
exec: 1 | ||
val it = () : unit | ||
exec: 2 | ||
val it = () : unit | ||
val it = () : unit | ||
val it = () : unit | ||
exec: 3 | ||
val it = () : unit | ||
- |
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,8 @@ | ||
val s = ref (new (counter ())); | ||
|
||
print "===TEST START===\n"; | ||
s := next (!s); | ||
s := next (!s); | ||
s := prev (!s); | ||
s := next (!s); | ||
s := next (!s); |
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,85 @@ | ||
#!/bin/bash | ||
|
||
hw2="https://raw.githubusercontent.com/AdiHarif/236319-Spr-2023/master/HW/Homework2/" | ||
hw3="https://raw.githubusercontent.com/AdiHarif/236319-Spr-2023/master/HW/Homework3/" | ||
hw4="https://raw.githubusercontent.com/AdiHarif/236319-Spr-2023/master/HW/Homework4/" | ||
|
||
tmpdir="selfcheck_tmp" | ||
test_files=("q1" "q2" "q3") | ||
required_files=("hw4_q1.sml" "hw4_q2.sml" "hw4_q3.sml" "dry.pdf") | ||
|
||
if [ -z "$2" ]; then | ||
echo "Usage: ./"$( basename "$0" )" <your submission zip file> <directory with previous solutions>" | ||
exit | ||
fi | ||
|
||
if [ ! -f "$1" ]; then | ||
echo "Submission zip file not found!" | ||
exit | ||
fi | ||
|
||
if [ ! -d "$2" ]; then | ||
echo "Directory with previous solutions not found!" | ||
exit | ||
fi | ||
|
||
rm -rf "$tmpdir" &> /dev/null | ||
if [ -d "$tmpdir" ] | ||
then | ||
echo "Cannot clear tmp directory. Please delete '$tmpdir' manually and try again" | ||
exit | ||
fi | ||
mkdir "$tmpdir" &> /dev/null | ||
|
||
yes | apt install zip &> /dev/null | ||
|
||
unzip "$1" -d "$tmpdir" &> /dev/null | ||
if [[ $? != 0 ]]; then | ||
echo "Unable to unzip submission file!" | ||
exit | ||
fi | ||
|
||
cd "$tmpdir" | ||
for f in "${required_files[@]}" | ||
do | ||
if [ ! -f $f ]; then | ||
echo "File $f not found!" | ||
exit | ||
fi | ||
done | ||
|
||
if [ $( ls | wc -l ) != ${#required_files[@]} ]; then | ||
echo "There are too many files in the submission" | ||
exit | ||
fi | ||
|
||
cp ../$2/* . &> /dev/null | ||
|
||
wget "${hw3}hw3_q1_def.sml" "${hw3}hw3_q2_def.sml" &> /dev/null | ||
if [ ! -f "hw3_q1_def.sml" ] || [ ! -f "hw3_q2_def.sml" ]; then | ||
echo "Unable to download def files from previous homeworks!" | ||
exit | ||
fi | ||
|
||
for test in "${test_files[@]}" | ||
do | ||
wget "$hw4$test.in" "$hw4$test.expected" "${hw4}hw4_${test}_def.sml" &> /dev/null | ||
sleep 3 | ||
if [ ! -f "$test.in" ] || [ ! -f "$test.expected" ] || [ ! -f "hw4_${test}_def.sml" ]; then | ||
echo "Unable to download test $test!" | ||
exit | ||
fi | ||
sml hw4_$test.sml < $test.in &> $test.rawout | ||
sed '1,/===TEST START===/d' $test.rawout > $test.out | ||
diff $test.out $test.expected | ||
if [[ $? != 0 ]]; then | ||
echo "Failed test $test!" | ||
exit | ||
fi | ||
done | ||
|
||
cd - &> /dev/null | ||
rm -rf "$tmpdir" | ||
|
||
echo "Ok to submit :)" | ||
exit |
Oops, something went wrong.