方案:(5(5))如何产生“ [英] Scheme: how to produce '(5 . (5))

查看:155
本文介绍了方案:(5(5))如何产生“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了各种利弊的组合,并追加生产'(5(5)),但我不能。有什么办法?

I have tried all kinds of combinations of cons and append to produce '(5 . (5)) but I couldn't. Is there any way?

推荐答案

目前听起来像比尔·克林顿的风险,这取决于你的意思是生产的。

At the risk of sounding like Bill Clinton, it depends on what you mean by "produce".

如果你的意思是产生在屏幕上打印为(5(5)),那么你几分运气的值,因为这值打印为(5)

If you mean "produce a value that prints on the screen as '(5 . (5)), then you're sort of out of luck, because this value prints as '(5 5).

有关一个类似的例子:我怎么产生数 1E-1 ?好吧,试着键入它;这是相同的0.1,如果你在1E-1型,它会打印为0.1。

For a similar example: how do I produce the number 1e-1 ? Well, try typing it in; this is the same as 0.1, and if you type in 1e-1, it's going to print as 0.1.

不过,您可以评估

#lang racket
(= 0.1 1e-1)

......,你会看到,他们是同一号码。

... and you'll see that they're the same number.

在以同样的方式,请评价

In the same way, try evaluating

#lang racket
(equal? '(5 . (5)) (list 5 5))

,你会看到,这些写相同值的两种方式。

and you'll see that these are two ways of writing the same value.

这篇关于方案:(5(5))如何产生“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆