Coursera Course: Programming Languages
来源:互联网 发布:mac桌面文件不能拖动 编辑:程序博客网 时间:2024/06/07 02:34
第一课作业
fun is_older (date1 : int*int*int, date2 : int*int*int) = if #1 date1 <> #1 date2 then #1 date1 < #1 date2 else if #2 date1 <> #2 date2 then #2 date1 < #2 date2 else if #3 date1 <> #3 date2 then #3 date1 < #3 date2 else falsefun number_in_month (ld : (int*int*int) list, m : int) = if null ld then 0 else let val tl_ans = number_in_month(tl ld, m) in if #2 (hd ld) = m then 1 + tl_ans else tl_ans endfun number_in_months (ld : (int*int*int) list, ms : int list) = if null ms then 0 else number_in_month(ld, hd ms) + number_in_months(ld, tl ms)fun dates_in_month (ld : (int*int*int) list, m : int) = if null ld then [] else let val tl_ans = dates_in_month(tl ld, m) in if #2 (hd ld) = m then (hd ld) :: tl_ans else tl_ans endfun dates_in_months (ld : (int*int*int) list, ms : int list) = if null ms then [] else dates_in_month(ld, hd ms) @ dates_in_months(ld, tl ms)fun get_nth (slist : string list, n : int) = if n = 1 then hd slist else get_nth(tl slist, n-1)fun date_to_string (date : int*int*int) = let val months = ["January","February","March","April","May", "June","July","August","September","October","November","December"] val year = Int.toString(#1 date) val month = get_nth(months, #2 date) val day = Int.toString(#3 date) in month ^ " " ^ day ^ ", " ^ year endfun number_before_reaching_sum (sum : int, nums : int list) = if sum <= 0 then ~1 else 1 + number_before_reaching_sum(sum - (hd nums), tl nums)fun what_month (day : int) = let val days = [31,28,31,30,31,30,31,31,30,31,30,31] in number_before_reaching_sum(day, days) + 1 endfun month_range (day1 : int, day2 : int) = if day1 > day2 then [] else what_month(day1) :: month_range(day1+1, day2)fun oldest (dates : (int*int*int) list) = if null dates then NONE else let val tl_ans = oldest(tl dates) in if isSome tl_ans andalso is_older(valOf tl_ans, hd dates) then tl_ans else SOME (hd dates) end
0 0
- Coursera Course: Programming Languages
- Programming Languages
- programming languages
- Programming / Languages / Comparison_and_Review
- Programming Languages Comparision
- Concepts in Programming Languages
- Timeline of programming languages
- Comparison of programming languages
- The Programming Languages Beacon
- Concepts in Programming Languages
- The Programming Languages Beacon
- Quotes about programming languages
- Thinking in Current Programming Languages
- The History of Programming Languages
- Design Concepts in Programming Languages
- Computer English - (2)Programming Languages
- CSE341: Programming Languages 学习笔记
- Kernel Programming Course
- 链表的归并排序
- HH的一万天
- 《leetCode》:Unique Paths
- 漫谈以太网交换机
- Html CSS
- Coursera Course: Programming Languages
- 从PDF中提取信息----PDFMiner
- Auction
- c++输入
- JSP防盗链接
- POJ 2255Tree Recovery 二叉树重建(根据前序遍历和中序遍历写出后序遍历)
- 脑子短路瞬间
- 给大家推荐几个NotePad++的插件
- 如何使用Clementine获得混淆矩阵