返回   cpper编程论坛 > 技术杂烩
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

技术杂烩 找不到地方的技术问题?这里!

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2007-11-21
初级会员
 
注册日期: 2007-11-21
帖子: 1
qius805 正向着好的方向发展
默认 Scheme高手帮帮忙

有个关于Scheme的问题要请教,要求用Scheme分别做个prefix calculator和一个 postfix calculator。
需要用到如下:
(prefix-eval 1st) where 1st is a list of numbers and binary operators,which,when interpreted in prefix evaluate to a number.
Your prefix evaluator needs to recognize the binary operators'+','-','*'and '/' as well as the unary operator 'chs'.
下面的例子可以做提示:
(prefix-eval '(1))
1

(prefix-eval '(+2 3))
5

(prefix-eval '(+*+1 chs 2 3 ch 4))
7

如果有高手能编出的,请与我联系。qius805@sina.com因为初涉及这个语言,所以想请高手支招~ 谢谢啦
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2007-12-24
liuxinyu 的头像
高级会员
 
注册日期: 2006-02-09
帖子: 303
文章: 48
liuxinyu 正向着好的方向发展
默认 回复: Scheme高手帮帮忙

这个是最基本的。
仿照sicp的evaluator一章最开始的例子就可以了。
引用:
作者: qius805 查看帖子
有个关于Scheme的问题要请教,要求用Scheme分别做个prefix calculator和一个 postfix calculator。
需要用到如下:
(prefix-eval 1st) where 1st is a list of numbers and binary operators,which,when interpreted in prefix evaluate to a number.
Your prefix evaluator needs to recognize the binary operators'+','-','*'and '/' as well as the unary operator 'chs'.
下面的例子可以做提示:
(prefix-eval '(1))
1

(prefix-eval '(+2 3))
5

(prefix-eval '(+*+1 chs 2 3 ch 4))
7

如果有高手能编出的,请与我联系。qius805@sina.com因为初涉及这个语言,所以想请高手支招~ 谢谢啦
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用



所有时间均为格林尼治时间 +9。现在的时间是 07:12 AM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2008,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0