简体   繁体   English

Racket - 将引用列表中的符号自动转换为小写

[英]Racket - turns symbols in quoted list to lowercase automatically

I have the following program in Racket with the language set to "determine from source" and output syntax set to "write": 我在Racket中有以下程序,语言设置为“从源确定”,输出语法设置为“写入”:

#lang r5rs
(define g '((w C C) (x A C) (y A B) (z B C)))

When I run it and type in the interactive prompt 当我运行它并输入交互式提示时

> g

I get 我明白了

{{w c c} {x a c} {y a b} {z b c}}

However, when I type the list directly to the prompt I get 但是,当我直接输入列表到我得到的提示

> '((w C C) (x A C) (y A B) (z B C))
{{w C C} {x A C} {y A B} {z B C}}

How can I prevent Racket from turning the symbols to lowercase? 如何防止Racket将符号转换为小写?

The R5RS standard requires the reader to hand symbols without case sensitivity. R5RS标准要求读者在没有区分大小写的情况下处理符号。 Most R5RS implementations will convert symbols with upper case symbols into lower case. 大多数R5RS实现都会将带有大写符号的符号转换为小写。 If you need to produce a symbol with upper case letters, you need to use string->symbol . 如果需要生成带大写字母的符号,则需要使用string->symbol

> (string->symbol "Hello")
Hello

Since many Scheme implementations supported case sensitivity, later standards changed the default to case sensitivity. 由于许多Scheme实现支持区分大小写,后来的标准将默认值更改为区分大小写。

See the (first!) question in the Scheme FAQ for a longer explanation: 请参阅方案常见问题解答中的(第一个!)问题以获得更长的解释:

http://community.schemewiki.org/?scheme-faq-language http://community.schemewiki.org/?scheme-faq-language

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM