Chinaunix首页 | 论坛 | 博客
  • 博客访问: 209340
  • 博文数量: 136
  • 博客积分: 2919
  • 博客等级: 少校
  • 技术积分: 1299
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 09:08
文章分类

全部博文(136)

文章存档

2013年(1)

2011年(135)

我的朋友

分类: LINUX

2011-11-18 11:17:23

  1. ;; mht created on Nov 15, 2011

  2. ;; convert-euro : list-of-numbers -> list-of-numbers
  3. ;; exchange rate is 1.22 euro for each dollar
  4. (define (convert-euro a-list-of-nums)
  5.   (cond
  6.     [(empty? a-list-of-nums) empty]
  7.     [else
  8.      (cons
  9.       ( * 1.22 (first a-list-of-nums))
  10.       (convert-euro (rest a-list-of-nums)))]))

  11. ;; test
  12. (convert-euro (cons 10 (cons 20 empty)))

  13. ;; convert-euro : number list-of-numbers -> list-of-numbers
  14. (define (convert-euro-1 rate a-list-of-nums)
  15.   (cond
  16.     [(empty? a-list-of-nums) empty]
  17.     [else
  18.      (cons
  19.       ( * rate (first a-list-of-nums))
  20.       (convert-euro-1 1.22 (rest a-list-of-nums)))]))

  21. ;; test
  22. (convert-euro-1 1.22 (cons 10 (cons 20 empty)))
阅读(369) | 评论(0) | 转发(0) |
0

上一篇:exam10.1.2

下一篇:exam14.2.1

给主人留下些什么吧!~~