When does "1..10" make sense?

I have a vague recollection of a programming language, where 1..10 means "range 1, up to and including 10 exclusive," similar to python range(1, 10) , but I don't have a foggy one that doesn’t particularly lend itself to searching. Any help?

If the answer is "python", please forgive me. I know a very small python.

+4
source share
9 answers

Haskell does this.

+5
source

Pascal supports this syntax. In fact, you can use this as a type, and I believe that it is also used to determine the boundaries of an array. (I'm not sure how standard Pascal is and how many Turbo Pascal extensions are.)

+6
source

This is Perl called the "Range Operator"

http://www.cs.cf.ac.uk/Dave/PERL/node38.html

+5
source

Groovy also uses this syntax.

http://groovy.codehaus.org/Collections

+3
source

F #, they are called sequence expressions

http://msdn.microsoft.com/en-us/library/dd233209.aspx (select F # examples to see the code)

+3
source

ruby!

+2
source

Since the OP has already received the answer they were looking for, and this has already become a list of languages ​​using the 1..n syntax, I will add one more.

Maple

The wiki page shows a good example.

 myfac := n -> product( i, i=1..n ); 

Please note that this is from 1 to 10 inclusive

+2
source

Ruby has very similar syntax ...

You can read more here: http://www.ruby-doc.org/core/classes/Range.html

+1
source

If it is an indefinite and distant memory, I would suggest that Pascal or Delphi is the most likely candidate for the language you are thinking about.

It is most often used in Pascal in case . See here for a syntax example: http://en.wikipedia.org/wiki/Switch_statement#Pascal

It can also be any of several other languages ​​that use this syntax, but without knowing a bit more about your programming history, I think it will still be Pascal / Delphi.

+1
source

Source: https://habr.com/ru/post/1343728/


All Articles