(* ** Course: Concepts of Programming Languages (BU CAS CS 320) ** Semester: Summer I, 2009 ** Instructor: Hongwei Xi (hwxi AT cs DOT bu DOT edu) *) // // Assignment Two (Due: Wednesday, June 2, 2010) // (* ****** ****** *) staload "assignment2.sats" (* ****** ****** *) dynload "assignment2_solu.dats" (* ****** ****** *) staload _(*anonymous*) = "prelude/DATS/list.dats" staload _(*anonymous*) = "prelude/DATS/list0.dats" extern fun string_implode (cs: list0 char): string = "atspre_string_implode" extern fun string_explode (str: string): list0 char = "atspre_string_explode" (* ****** ****** *) implement main () = let // val () = print ("Testing the function [palindrome_test] is started.\n") val s1 = "abcdefghijklmnopqrstuvwxyz" val ans1 = palindrome_test (s1) val () = assert (ans1 = false) val s1' = string_implode (list0_reverse (string_explode s1)) val s2 = s1 + s1' val ans1 = palindrome_test (s2) val () = assert (ans1 = true) val () = begin print ("Testing the function [palindrome_test] is finished successfully.\n") end // end of [val] // val () = print ("Testing the function [string_perm_test] is started.\n") val () = assert (string_perm_test ("able", "bale")) val () = assert (~string_perm_test ("able", "label")) val () = begin print ("Testing the function [string_perm_test] is finished successfully.\n") end // end of [val] // val () = print ("Testing the function [piglatin_trans] is started.\n") val () = assert (piglatin_trans "able" = "ableyay") val () = assert (piglatin_trans "stripe" = "ipestray") val () = begin print ("Testing the function [piglatin_trans] is finished successfully.\n") end // end of [val] in // empty end // end of [main] (* ****** ****** *) (* end of [assignment2_test.dats] *)