Discussions related to Visual Prolog
daveplummermd
VIP Member
Posts: 80
Joined: 18 Jul 2006 17:18

List Construction

Unread post by daveplummermd »

I remember seeing somewhere an abbreviated method to construct a list of sequential integers.
I am looking for:

Code: Select all

List=[1,2,3,4,5]
to be achieved with a shortcut looking something like this

Code: Select all

List=[1..5]
But, I can not remember or find the proper syntax for that abbreviated method.
Dave Plummer
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: List Construction

Unread post by Thomas Linder Puls »

We do not have such a syntax. But you can use a list comprehension like this:

Code: Select all

List = [ I || I = std::fromTo(1, 5) ]
Regards Thomas Linder Puls
PDC
daveplummermd
VIP Member
Posts: 80
Joined: 18 Jul 2006 17:18

Re: List Construction

Unread post by daveplummermd »

Thank you!
Dave Plummer
Post Reply