This code isn’t compiling for me: let countDown = [5L .. −1L .. 0L];;
I have a book (page 33) that says it should return this:
val countDown : int list = [5L; 4L; 3L; 2L; 1L; 0L]
Compiler Error:
Program.fs(42,24): error FS0010: Unexpected character '−' in expression
>
> let countDown = [5L .. −1L .. 0L];;
let countDown = [5L .. −1L .. 0L];;
-----------------------^
The book’s wrong. but why? is it an update to the language? what is the way to achieve that?
Edit: the problem was that the − character copied from the PDF, isn’t the - character.
Your original code works fine for me even without the modifications that Igor suggested:
A possible subtle error is that if you (for example) pasted the code from Word (or some other program), it may have replaced the
-symbol with some other type of dash that looks the same, but has actually a different code.Another way to break the code is to remove some spaces – for example, there must be a space between
..and-1L. Otherwise, I don’t see any reason why it shouldn’t work.