(* CS 2SC3 / SE 2S03 * Assignment 1 Solution * * Author: W. M. Farmer * Revised: October 6, 2009 * *) let direction (x,y) = if x = 0. && y < 0. then "south" else if x = 0. && y > 0. then "north" else if x < 0. && y = 0. then "west" else if x > 0. && y = 0. then "east" else if x < 0. && y < 0. then "southwest" else if x < 0. && y > 0. then "northwest" else if x > 0. && y < 0. then "southeast" else if x > 0. && y > 0. then "northeast" else "no direction" ;; let test_direction (x,y) = let x_string = string_of_float x in let y_string = string_of_float y in let output_string = direction (x,y) in print_string ("When direction is applied to " ^ "(" ^ x_string ^ "," ^ y_string ^ "), the output is " ^ "\"" ^ output_string ^ "\".\n") ;; test_direction (0.,-0.4) ;; test_direction (0.,6.6) ;; test_direction (-4.,0.) ;; test_direction (23.6,0.) ;; test_direction (-0.677,-56.) ;; test_direction (-1000000.,79.9) ;; test_direction (0.00009,-0.00007) ;; test_direction (4.4,0.23) ;; test_direction (0.,0.) ;;