I have a vague memory of a programming language where 1..10
meant "the range 1 inclusive to 10 exclusive", similar to python's range(1, 10)
, but I haven't the fog开发者_开发问答giest which, and this doesn't particularly lend itself to searches. Any help?
If the answer's "python", please forgive me. I know very little python.
Pascal supports that syntax. You can actually use this as a type, and I believe it's also used in specifying array bounds. (I'm not sure how much of this is standard Pascal and how much is Turbo Pascal extensions.)
Haskell does it.
It is Perl, called the "Range Operator"
http://www.cs.cf.ac.uk/Dave/PERL/node38.html
Groovy uses this syntax, too.
http://groovy.codehaus.org/Collections
F#, they are called Sequence Expressions
http://msdn.microsoft.com/en-us/library/dd233209.aspx (select the F# examples to see the code)
Ruby!
Since the OP already got the answer they were looking for, and this has kind of become a list of languages that use 1..n syntax, I'll add one more.
Maple
The wiki page shows a good example
myfac := n -> product( i, i=1..n );
Note however that this is 1 to 10 inclusive
Ruby has VERY similar syntax...
You can read more here: http://www.ruby-doc.org/core/classes/Range.html
If it's a vague and distant memory, then I'd guess that Pascal or Delphi is the most likely candidate for the language you're thinking of.
It's most commonly used in Pascal in a case
statement. See here for example syntax: http://en.wikipedia.org/wiki/Switch_statement#Pascal
It could also be any of a number of other languages that use this syntax, but without knowing a bit more about your programming history, my guess would still be Pascal / Delphi.
精彩评论