计算机科学分类程序设计语言.pptxVIP

  • 2
  • 0
  • 约1.63千字
  • 约 6页
  • 2022-04-25 发布于北京
  • 举报
Programming LanguagesDan GrossmanLet Expressions to Avoid Repeated ComputationAvoid repeated recursionConsider this code and the recursive calls it makesDon’t worry about calls to null, hd, and tl because they do a small constant amount of workfun bad_max (xs : int list) = if null xs then 0 (* horrible style; fix later *) else if null (tl xs) then hd xs else if hd xs bad_max (tl xs) then hd xs else bad_max (tl xs)let x = bad_max [50,49,…,1]let y = bad_max [1,2,…,50]Dan Grossman, Programming LanguagesFast vs. unusableif hd xs bad_max (tl xs)then hd xselse bad_max (tl xs)bm [50,…]bm [49,…]bm

文档评论(0)

1亿VIP精品文档

相关文档