Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence Enumeration #661

Closed
ritchje opened this issue Jan 23, 2018 · 5 comments
Closed

Sequence Enumeration #661

ritchje opened this issue Jan 23, 2018 · 5 comments
Milestone

Comments

@ritchje
Copy link

ritchje commented Jan 23, 2018

Description

Sequence enumeration does not work.

Steps to Reproduce

[1,...,10] = Error 2034: Unexpected token in expression: ... in 'DEFAULT' (console) at line 1:4

Versions

Version: 2.5.2
Build date: 2017 Sep 11 10:27 CEST
Git commit description: Release/2.5.2.

@peterwvj
Copy link
Member

peterwvj commented Jan 23, 2018

Ranges currently only work for sets:

{1,...,10} = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

So it's not a bug. You could do:

[i | i in set{1,...,10}] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Does that help?

@peterwvj peterwvj added this to the v2.5.8 milestone Jan 23, 2018
@peterwvj
Copy link
Member

peterwvj commented Jan 23, 2018

If order is important, you could define a function like this:

functions
seqRange: int * int -> seq of int
seqRange(f,t) ==
if f > t then []
else [f] ^ seqRange(f+1,t);

@nickbattle
Copy link
Contributor

PJ is right, there is no such thing as a sequence range. But I've often wondered why not, given that set ranges exist. They would be very useful sometimes.

You could submit a request for a language extension to the Language Board? But it would take a while to get approved/implemented.

@ritchje
Copy link
Author

ritchje commented Jan 23, 2018

@peterwvj @nickbattle Page 63 of the VDM manual mentions sequence enumeration? Maybe I've misinterpreted it?

@peterwvj
Copy link
Member

peterwvj commented Jan 23, 2018

Sequence enumerations are just sequence constructors, e.g. {1,2,3}. So it's not a range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants