R5RS is the Revised5 Report on the Algorithmic Language Scheme.参考http://www.schemers.org/Documents/Standards/R5RS/

racket let 用法:

(let ([id val-expr] ...) body ...+)

(let proc-id ([id init-expr] ...) body ...+)
The first form evaluates the val-exprs left-to-right, creates a newlocation for each id, and places the values into the locations. It then evaluates the bodys, in which the ids are bound. The last bodyexpression is in tail position with respect to the let form. The ids must be distinct according to bound-identifier=?.

Examples:

> (let ([x 5]) x)

5

> (let ([x 5])
    (let ([x 2]
          [y x])
      (list y x)))

'(5 2)

The second form evaluates the init-exprs; the resulting values become arguments in an application of a procedure (lambda (id ...) body ...+), where proc-id is bound within the bodys to the procedure itself.

Example:

> (let fac ([n 10])
    (if (zero? n)
        1
        (* n (fac (sub1 n)))))

3628800

syntax

(let* ([id val-expr] ...) body ...+)

Like let, but evaluates the val-exprs one by one, creating a locationfor each id as soon as the value is available. The ids are bound in the remaining val-exprs as well as the bodys, and the ids need not be distinct; later bindings shadow earlier bindings.

Example:

> (let* ([x 1]
         [y (+ x 1)])
    (list y x))

'(2 1)

r5rs:

library syntax:  (let <bindings> <body>) 

Syntax: <Bindings> should have the form ((<variable1> <init1>) ...),

where each <init> is an expression, and <body> should be a sequence of one or more expressions. It is an error for a <variable> to appear more than once in the list of variables being bound.

Semantics: The <init>s are evaluated in the current environment (in some unspecified order), the <variable>s are bound to fresh locations holding the results, the <body> is evaluated in the extended environment, and the value(s) of the last expression of <body> is(are) returned. Each binding of a <variable> has <body> as its region.

(let ((x 2) (y 3))
  (* x y))                              ===>  6

(let ((x 2) (y 3))
  (let ((x 7)
        (z (+ x y)))
    (* z x)))                           ===>  35

See also named let, section 4.2.4.

library syntax:  (let* <bindings> <body>) 

Syntax: <Bindings> should have the form ((<variable1> <init1>) ...),

and <body> should be a sequence of one or more expressions.

Semantics: Let* is similar to let, but the bindings are performed sequentially from left to right, and the region of a binding indicated by(<variable> <init>) is that part of the let* expression to the right of the binding. Thus the second binding is done in an environment in which the first binding is visible, and so on.

(let ((x 2) (y 3))
  (let* ((x 7)
         (z (+ x y)))
    (* z x)))                     ===>  70

let区别(关于racket和r5rs)的更多相关文章

  1. racket

    let 和 let* 区别 ``` racket // 这是对的 (let* ([x (random 4)][o (random 4)] [diff (number->string (abs ( ...

  2. Scheme r5rs letrec的用法

    说明,这是r5rs的用法. (letrec ((<variable> <init>) ...) <body>) 假设((<variable> <i ...

  3. racket学习-call/cc (let/cc)

    Drracket continuation 文中使用let/cc代替call/cc Racket文档中,let/cc说明为: (let/cc k body ...+) Equivalent to (c ...

  4. c#与java的区别

    经常有人问这种问题,用了些时间java之后,发现这俩玩意除了一小部分壳子长的还有能稍微凑合上,基本上没什么相似之处,可以说也就是马甲层面上的相似吧,还是比较短的马甲... 一般C#多用于业务系统的开发 ...

  5. jquery和Js的区别和基础操作

    jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...

  6. 【原】nodejs全局安装和本地安装的区别

    来微信支付有2年多了,从2年前的互联网模式转变为O2O模式,主要的场景是跟线下的商户去打交道,不像以往的互联网模式,有产品经理提需求,我们帮忙去解决问题. 转型后是这样的,团队成员更多需要去寻找业务的 ...

  7. 探究@property申明对象属性时copy与strong的区别

    一.问题来源 一直没有搞清楚NSString.NSArray.NSDictionary--属性描述关键字copy和strong的区别,看别人的项目中属性定义有的用copy,有的用strong.自己在开 ...

  8. X86和X86_64和X64有什么区别?

    x86是指intel的开发的一种32位指令集,从386开始时代开始的,一直沿用至今,是一种cisc指令集,所有intel早期的cpu,amd早期的cpu都支持这种指令集,ntel官方文档里面称为&qu ...

  9. Java中Comparable与Comparator的区别

    相同 Comparable和Comparator都是用来实现对象的比较.排序 要想对象比较.排序,都需要实现Comparable或Comparator接口 Comparable和Comparator都 ...

随机推荐

  1. 【Git】代码托管-从基本设置开始

    Git是现在比较火的一款代码托管工具,之前也有在使用GitHub,是用GitHub for windows一个图形管理的界面,如果没有这个图形控制界面的话我估计自己又要放弃了.用BASH命令来实现托管 ...

  2. jquery实现二级联动

    闲来没事,写点jquery练练手. <!--json代码部分 新建文件liandong.json--> var pron_city = { '省':['all'], '北京':[ {'市' ...

  3. 关于SQL SERVER 2008 R2发布订阅功能

    实现功能:主服务器维护数据的变更,从服务器需要时同步主服务器的数据. 配置:主从服务器均为SQL SERVER 2008 R2. 实现方法: 预备: 1.主从服务器需建立同一账户名及密码的账户(当时我 ...

  4. 如何使用Prism框架的EventAggregator在模块间进行通信

    目的 本文主要介绍如何使用Prism类库提供的事件机制在松耦合组件之间相互通信,Prism类库的事件机制建立在事件聚合服务之上,允许发布者和订阅者通过事件进行通信,不需要彼此之间引用. 事件聚合 Ev ...

  5. Effective Java设定游戏 - 就是爱Java

    首先,我们先设定游戏,一个网页游戏的基本场景,主角拥有各种能力,但一开始数值都只有系统初始,随着故事的发展,会接触到各种不同的场景,获得提升角色的道具与装备,来参与更高难度的任务. 阅读全文>& ...

  6. inotifywait实现目录监控

    http://blog.csdn.net/firefoxbug/article/details/8188804

  7. 几道C语言的题目!

    注:编译环境 VC2010,系统WIN7 64位,其他编译环境和系统未测试   1-1. 编程,输入n,输出如下例(n=5)所示的图形: ***** ***** ***** ***** ***** # ...

  8. OpenWrt修改

    openwrt如何编译修改界面的顶部.底部信息.LOGO图片 2011-06-02 16:20:03  浏览次  以Atheros71xx为例,修改路径为:trunk/build_dir/target ...

  9. AIX5.3CPU占用高的问题核查

    AIX5.3 CPU占用高问题核查步骤 1.topas查看占用cpu占用最高的进程的PID 2.执行: ps -mp PID -o THREAD 以查找相应进程下所有正在占用 CPU 的线程的TID ...

  10. Zookeeper 1、Zookeeper 定义与工作原理

    1.什么是Zookeeper » Zookeeper 是 Google 的 Chubby一个开源的实现,是 Hadoop 的分布式协调服务 » 它包含一个简单的原语集,分布式应用程序可以基于它实现同步 ...