Skip to content

Commit

Permalink
Assignment 5 submission
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-byrne committed Sep 20, 2024
1 parent f4ea9ca commit 012043a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 126 deletions.
11 changes: 11 additions & 0 deletions src/ica05/ica5.sml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
(*
* Author: Christian Byrne
* Date: 9/19/24
* ICA 5
* Description: Practice functions in SML,
* focusing on pattern matching
* and recursion.
*)


(* Question 1 *)
fun log2(1) = 0
| log2(n) = 1 + log2(n div 2);
Expand Down Expand Up @@ -46,3 +56,4 @@ fun combineLists([], [], operator) = []
| combineLists([], li2, operator) = hd(li2) :: combineLists([], tl(li2), operator)
| combineLists(li1, [], operator) = hd(li1) :: combineLists(tl(li1), [], operator)
| combineLists(li1, li2, operator) = operator(hd(li1), hd(li2)) :: combineLists(tl(li1), tl(li2), operator);

123 changes: 0 additions & 123 deletions src/ica6.sml

This file was deleted.

5 changes: 2 additions & 3 deletions tests/utils.sml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fun valueToStringInt(n: int) = Int.toString(n);
fun valueToStringBool(true) = "true"
| valueToStringBool(false) = "false";

(* Function to convert int list to string (example) *)
(* Function to convert int list to string *)
fun valueToStringIntList([]) = "[]"
| valueToStringIntList(lst) = "[" ^ String.concatWith ", " (List.map Int.toString lst) ^ "]";

Expand Down Expand Up @@ -71,7 +71,6 @@ fun runTestCasesIntListInt([]) = ()
end;

(* Generic test runner for int list -> int list functions *)

fun runTestCasesIntListIntList([]) = ()
| runTestCasesIntListIntList(testCaseList) =
let
Expand All @@ -90,7 +89,7 @@ fun runTestCasesIntListIntList([]) = ()
if result <> expected then raise Fail("Test failed") else runTestCasesIntListIntList(tl(testCaseList))
end;

(* Generic test runner for functions *)
(* Generic test runner for int list -> int list -> int list -> int list functions *)
fun runTestCasesIntListIntListOperatorToIntList([]) = ()
| runTestCasesIntListIntListOperatorToIntList(testCaseList) =
let
Expand Down

0 comments on commit 012043a

Please sign in to comment.