惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Simon Willison's Weblog
Simon Willison's Weblog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
Last Week in AI
Last Week in AI
月光博客
月光博客
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
U
Unit 42
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
H
Hacker News: Front Page
Recent Announcements
Recent Announcements
C
CXSECURITY Database RSS Feed - CXSecurity.com
Latest news
Latest news
小众软件
小众软件
P
Palo Alto Networks Blog
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
S
Secure Thoughts
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
O
OpenAI News
S
Securelist
云风的 BLOG
云风的 BLOG
H
Help Net Security
T
Troy Hunt's Blog

博客园 - 豆豆の爸爸

IDEA 2024的零卡死配置 10分钟揭秘大模型的原理 苹果容器Apple container是做什么用的? pnpm 10.14 支持JavaScript运行时的安装了 白话Docker:用Web应用实例深入容器 用 rake 合并多个 JS 文件,并且用 Google Closure Compiler 压缩代码 HTML 5 就是 Web Application JS程序员的一天 Google Map 类实例在类式继承中的实现 写入 cookie 的过期时间时在GMT或UTC时间格式上的兼容问题 “当 HTML 5 来敲门”专题沙龙(上海)活动 PHP 的 Smarty 模板页中分离JS并避开literal标签的解决方法 Google Maps(Google 地图) V3 在 IE7 浏览器中拖放其容器时图块被覆盖的 bug 2010年我的个人总结 [译]用 Closure Compiler 编写更好的 OO 的 JavaScript 《JS高级程序设计(第2版)》书评 [译]在 Firebug 中的表格化日志 在 Notepad++ 运行 Closure Linter 来校验JS代码 在 Notepad++ 运行 Closure Compiler 工具来解析并压缩JS
使用 IronScheme 进入 Scheme 编程语言的世界 - 豆豆の爸爸
豆豆の爸爸 · 2010-12-12 · via 博客园 - 豆豆の爸爸

用 Scheme 程序说声:hello world。先打开你的编辑器,创建一个称为 hello.ss 的文件,然后将下面的文本内容保存进去:

;hello.ss
(import (rnrs))

(begin
;显示 hello 文字
  (display "hello world.")
  (newline)
)

第1行是注释。Scheme 会把分号(;)及在这行它后面的文本内容忽略掉。

begin 是 Scheme 传输进入从属语句段(subform)序列的一种方式。在上面的示例中有2个从属语句段。第1段 display 处理函数的调用:将它的实参(字符串"hello world.")输出到控制台(或者“标准输出”)。第2段是 newline 处理函数的调用:输出了一个回车。

想要运行该程序的话,打开 IronScheme 控制台,在命令行中输入:

(load "E:\\work\\hello.ss")

Scheme 会执行 hello.ss 中的内容,输出 hello world.再后跟一个回车。

ironscheme_1

在《高阶函数:用作参数、函数生成的函数和匿名函数》中,用匿名函数计算给定数字的平方:

;square.ss
(import (rnrs))

;定义 square 函数
(define square
  ;匿名函数
  (lambda (x)
    (* x x)
  )
)
;调用 square 函数,然后显示
(display (square 3))
(newline)
(display (square 4))
(newline)

执行 square.ss 内容的结果如图:

ironscheme_2

在 abruzzi 的《FP》分享中,用apply处理函数对list的参数进行了累加:

;list.ss
(import (rnrs))
(define (sum argList)
  (apply + argList)
)
(define p '(1 2 3 4 5 6))
(display (sum p))
(newline)

在上面的代码中请注意:用单引号来指定list,也可以写成:

(list 1 2 3 4 5 6)

参考:

Teach Yourself Scheme in Fixnum Days()

(完)