Malcolm Groves
Subtracting from the sum of human knowledge
 
  Index

  Home
Projects
Writing
About Me

 
   
  Blog Categories

  All Posts
Borland
ECO
Personal
Photos
Projects
Misc.

 
   
  Recent Blog Entries

 

 
   
  Previous Posts

 
July 2005
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Jun   Aug


 
   
 
 
Recent Posts
Click to see the XML version of this web page.

 

Monday, 4 July 2005

OCL : subSequence

I think I've mentioend before that I've been working on an internal website using ASP.NET and ECO II. Partly because replacing the current site (based on static HTML) is going to make my life a lot easier, but also as I kinda miss coding as a day job, and of course if you want to really learn a new technology like ECO, there's no substitute for actually building and deploying an app into production.

Anyway, one of the things I wanted to do was to display summary lists of items on the main page of the site. You know, recently posted items, important upcoming dates, last 10 posts to the SE mailing list, etc. Most of this is easy, OCL like the following will pull out all Items in reverse order (ie. most newest to oldest).

Item.allInstances->orderdescending(ModifiedTime)

Problem is, I don't want to display all Items, only the most recent items, say, the last 10. Enter the subSequence operator:

Item.allInstances->orderdescending(ModifiedTime)->subSequence(1,10)

With this, I have a list of 10 Items, starting at position 1 in my list of Items ordered by ModifiedTime. Perfect!

|