Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheme - How to use "." as a symbol

Tags:

scheme

I want to do something like:

(car '(. a))

and get

.

as a result.

For example, if you type

'.

into the console you will get the output that I want. The problem is that I don't want to have an apostrophe infront of all of the . in a list.

Any guidance?

like image 398
Lebowski156 Avatar asked Dec 22 '25 11:12

Lebowski156


1 Answers

In Scheme's read syntax, a standalone dot is special. '. won't get you a dot symbol; it's invalid syntax. (If it works in your implementation, then that's just a special quirk of your implementation.)

Instead, you have to escape it. In most Scheme implementations, you can either use '|.| or '\..

(car '(\. a))   ; returns the same thing as (string->symbol ".")
(car '(|.| a))  ; likewise
like image 98
Chris Jester-Young Avatar answered Dec 24 '25 09:12

Chris Jester-Young



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!