| <<O>> Difference Topic AckermannNoviceExample (r1.9 - 28 Apr 2005 - TWikiGuest) |
| <<O>> Difference Topic AckermannNoviceExample (r1.8 - 31 Jan 2005 - LiYan) |
| <<O>> Difference Topic AckermannNoviceExample (r1.7 - 25 Jan 2005 - LiYan) |
| Added: | |
| > > | 展示架 生物反应器 笔记本电脑 成人用品 翻译 鲜花 移民 翻译公司 租房 游戏 游戏下载 摸屏 壁纸 服务器 爱滋病 办公自动化 出国 短信 干燥设备 交友 聊天 门禁 内衣 升降机 视频 写真 仪器仪表 移动存储 音乐 自考 算命 惠普 诺基亚 体育彩票 网页制作 前列腺 索尼 宠物 大连 电力 福利彩票 个人主页 广告公司 国际贸易 会计 计算机等级考试 交通 宽带 免费空间 农业 企业文化 人才 人才网 设计 手机报价 图书 网络 网络游戏 物业管理 西门子 小灵通 幼儿教育 幼儿园 娱乐 注册会计师 财务 财务管理 出国留学 电脑培训 多媒体 翻译软件 飞机票 购物 管理 婚纱摄影 激光 计算机培训 空间 律师 律师事务所 贸易 美容美发 模型 纳米 商标 数据库 通讯 网络安全 项目管理 鞋 雅思 英语培训 园林 招标 纸 中医 |
| <<O>> Difference Topic AckermannNoviceExample (r1.6 - 13 Jan 2005 - DanielBonniot) |
| <<O>> Difference Topic AckermannNoviceExample (r1.5 - 07 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | */ |
| > > | */ |
| <<O>> Difference Topic AckermannNoviceExample (r1.4 - 10 Jan 2004 - IsaacGouy) |
| Changed: | |
| < < | */ |
| > > | */ |
| <<O>> Difference Topic AckermannNoviceExample (r1.3 - 27 Aug 2003 - IsaacGouy) |
| Added: | |
| > > | %META:TOPICMOVED{by="IsaacGouy" date="1062001624" from="Doc.AckermannBeginnerExample" to="Doc.AckermannNoviceExample"}% |
| <<O>> Difference Topic AckermannNoviceExample (r1.2 - 26 Aug 2003 - IsaacGouy) |
| Changed: | |
| < < | 4) nicec --sourcepath=.. -a ackermann.jar ackermann 5) java -jar ackermann.jar 8 |
| > > | 4) compile the source code \ackermann> nicec --sourcepath=.. -a ackermann.jar ackermann 5) run the jar file \ackermann> java -jar ackermann.jar 8 |
| Changed: | |
| < < | \projects\ackermann> nicec ackermann \\ FAILS! |
| > > | \projects> nicec ackermann OK |
| Changed: | |
| < < | \projects> nicec ackermann \\ OK |
| > > | \projects\ackermann> nicec --sourcepath=.. ackermann OK |
| Changed: | |
| < < | \projects\ackermann> nicec --sourcepath=.. ackermann \\ OK |
| > > | \projects\ackermann> nicec ackermann FAILS! the compiler will try to find \projects\ackermann\ackermann |
| <<O>> Difference Topic AckermannNoviceExample (r1.1 - 26 Aug 2003 - IsaacGouy) |
| Added: | |
| > > |
%META:TOPICINFO{author="IsaacGouy" date="1061922180" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="CodeExamples"}%
/*
From the command line
1) create a directory ackermann
2) cd into directory ackermann
3) save this source code as main.nice in directory ackermann
4) nicec --sourcepath=.. -a ackermann.jar ackermann
5) java -jar ackermann.jar 8
*/
void main(String[] args){
let n = toSingleInt(args);
println("Ack(3," + n + "): " + ack(3,n));
}
int ack(int m, int n){
if (m == 0) return n + 1;
if (n == 0) return ack(m-1, 1);
return ack(m-1, ack(m, n-1));
}
int toSingleInt(String[] s){
try { return Integer.parseInt(s[0]); }
catch (Exception e){ return 1; } }
/* Notes - Compile & Run
The Nice compiler compiles PACKAGES (directories) not files,
so we must tell the compiler which directory contains the
package directory (ackermann) not which directory contains
the file (main.nice).
\projects\ackermann> nicec ackermann \\ FAILS!
\projects> nicec ackermann \\ OK
\projects\ackermann> nicec --sourcepath=.. ackermann \\ OK
Let's make the compiler output to a jar file (ackermann.jar):
\projects\ackermann> nicec --sourcepath=.. -a ackermann.jar ackermann
nice.lang: parsing
ackermann: parsing
ackermann: typechecking
ackermann: generating code
ackermann: linking
ackermann: writing in archive
nice.lang: writing in archive
Let's run the program:
\projects\ackermann> java -jar ackermann.jar
Ack(3,1): 13
\projects\ackermann> java -jar ackermann.jar 8
Ack(3,8): 2045
*/
-- IsaacGouy - 26 Aug 2003 |
| Topic AckermannNoviceExample . { View | Diffs | r1.9 | > | r1.8 | > | r1.7 | More } |
|
Revision r1.1 - 26 Aug 2003 - 18:23 GMT - IsaacGouy Revision r1.9 - 28 Apr 2005 - 11:47 GMT - TWikiGuest |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |