简体   繁体   中英

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":

#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?

The R5RS standard requires the reader to hand symbols without case sensitivity. Most R5RS implementations will convert symbols with upper case symbols into lower case. If you need to produce a symbol with upper case letters, you need to use string->symbol .

> (string->symbol "Hello")
Hello

Since many Scheme implementations supported case sensitivity, later standards changed the default to case sensitivity.

See the (first!) question in the Scheme FAQ for a longer explanation:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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