4 ms·
Well, Scheme has a bunch of syntax as well. (list '(1. . #\#) -5/6+7.s-8i `(1 ,@2) 1@1 ;hmmm, no unquote splicing c
by GregBuchholz 9y ago
Well, Scheme has a bunch of syntax as well.
(list '(1. . #\#)
-5/6+7.s-8i
`(1 ,@2)
1@1 ;hmmm, no unquote splicing comma ;-)
10# ;surprised?
(list #i+1 +1i 1+i) ;complicated or complex?
#e-1e10i ;Old MacDonald?
"(* 9 10)" #())
...how many can you guess without running the example? (I checked it with Dr. Racket under R5RS mode)
- soegaard 9y agoApropos: The meaning of # in Scheme number syntax: https://stackoverflow.com/q/10935110/23567 https://stackoverflow.com/q/10935110/23567
- didibus 9y agoHum, I confess, there's some weird ones. 1) A list of 1.0 and the pound char. 2) I'm guessing a complex number. 3) A list of 1 and an explicitly evaluated 2. 4) Hum, would it just be a symbol? 5) I am surprised. Maybe just another symbol? 6) More complex numbers. 7) Another complex number? 8) A string 9) An empty vector. Without the complex numbers, which I admit I've never used, it's not that bad. They're just shortend, you can use list, vector, quote, unquote, unquote-splicing and quasiquote functions instead. I think there's a function for char too, name->char I think. The ones that are weird are 1@1 and 10#. Anyways, there's a bit more syntax it's true, but all of that is literals. I'm not sure that counts as syntax, I guess it does. So ya, there's a little more than I said. Maybe it's easier to say I can explain the semantics in one minute and the syntax in two minutes?
- GregBuchholz 9y ago1) Improper list, or a cons cell. Quote and dotted pair notation are pretty common "in the wild". http://download.plt-scheme.org/doc/html/guide/Pairs__Lists__and_Scheme_Syntax.html http://download.plt-scheme.org/doc/html/guide/Pairs__Lists__... 2) Yup, complex number. 3) Another improper list. 4) Imaginary number in polar coordinate notation 5) # at the end of a numbers are to express inexactness, and are equivalent to a zero digit, so that express is 100. 6) The first one in that list (#i+1) is actually just 1.0, no imaginary part. The #i notation is for inexact numbers. The other two are the complex numbers i and 1+i. http://www.delorie.com/gnu/docs/guile/r5rs_54.html http://www.delorie.com/gnu/docs/guile/r5rs_54.html 7) Yes, an exact complex number. Interestingly enough, Dr. Racket in R5RS mode accepts that just fine, but Guile doesn't seem to like it. 8,9) Yes. For the full syntax of scheme see: http://www.scheme.com/tspl2d/grammar.html http://www.scheme.com/tspl2d/grammar.html
- didibus 9y agoWell, I've learned some things. I'm still confused about '(1. . #\#) So it's a pair containing 1.0 and pound? It's the 1. I find surprising. You can omit the number after the dot? Oh, and what's improper about `(1 ,@2) ? Wouldn't it evaluate to (1 2) ?
- GregBuchholz 9y agoIn "'(1. . #\#)" the "1." is a number. You are correct that you don't need digits after the decimal point. And #\# is just the pound character. `(1 ,2) is a proper list, and `(1 ,@2) is an improper list. You'll want to check out unquote-splicing: http://www.cs.rpi.edu/academics/courses/fall00/ai/scheme/reference/schintro-v14/schintro_129.html#SEC182 http://www.cs.rpi.edu/academics/courses/fall00/ai/scheme/ref...