Skip to main content
    Country/region select      Terms of use
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

Note: if you've recently posted an answer, I may not have seen it yet because of replication delay.

Another note: Formulas that leave an empty element on the end, I do not consider correct.

So far, Nathan Freeman has posted the shortest formula that works, at 73 characters.

I'm having fun and learning things by looking at the formulas people are posting (I didn't know that := assignment statements returned a value!). My own best answer is much shorter than it was originally from incorporating the tricks others have come up with. Here's my solution using combinatoric operators before looking at Nathan's formula:

d:=0:1:2:3:4:5:6:7;@text(@Subset(d*64*+d*8*+d+1;@Count(i:=items)))+". "+i

This is the same length as Nathan's answer, and is based on the same principle. It has a slight performance edge for generating 512 elements rather than 625 as Nathan's does. However, I'm using one trick he didn't by assigning a temporary variable to avoid repeating the longer name "Items."

Combining these, yields the following:

i:=0:1:2:3:4;j:=i*5*+i;@Subset(@Text(j*25*+j+1);@Count(o:=items))+". "+o

which gets us down to 72 characters.

If we allow the use of @Eval, we can do this:

c:=1;@Text(@Eval("1"+@Repeat(":(c:=c+1)";@Count(i:=Items)-1)))+". "+i

for 69 characters.

I'm sure someone can come up with some clever idea to reduce this further, but we've probably taken it to the point of absurdity already. Of course, as one respondent noted, the goal in a real application is not to have the shortest possible formula, but to have one that combines the advantages of performance and readability. For that purpose, if developing for version 6.0 or later, you probably would use @Transform to generate the list of numbers. Circumstances alter cases, though. If you have an application where performance is needed more than readability -- a view column formula, say, in a database with many documents -- *+ might be the best choice.

Andre Guirard | 5 April 2007 10:12:00 AM ET | Plymouth, MN, USA | Comments (1)

Search this blog 


    About IBM Privacy Contact