Intercalate Logo
Intercalate is illuminating, enabling, appealing.
Intercalate inspires visions of vistas, sensations of superiority, flights of fancy.

Example 1 Intercalate as a mail-merge program

Using Intercalate as a mail-merge program would be overkill. You probably already have tools that do that.  But the concept of merging the content of one file with another is a familiar one and it serves as a good starting point to understanding Intercalate.

Using Intercalate, you can write a form letter and manage an address list, just as you might using your mail-merge program. In our nomenclature, the form letter is called the template and the address list the dictionary or property list. The output is a realization.

Naturally your mail-merge program can perform simple keyword lookup and substitution. So can Intercalate.
 
Template Property List Realization
Dear Mr. $Name: $, + Name = Smith; = Dear Mr. Smith,
 
Of course some mail-merge programs iterate over lists. 
Intercalate can, too.
$for Person$
 Dear Mr. $Name: $,
$end$
+ Person = (
 {Name = Smith;},
 {Name = Jones;}
)
= Dear Mr. Smith,
Dear Mr. Jones,
 
But can it also test values of the properties and customize the output to match? 
Intercalate can.
$for Person$
 Dear
 $if Gender="M"$
  Mr. $else$ Ms. $end$
 $Name: $,
$end$
+ Person = (
 {Name = Smith; Gender = M;},
 {Name = Jones; Gender = F;}
)
= Dear Mr. Smith,
Dear Ms. Jones,
 
Can it supply default values for missing properties in the list? 
Intercalate can.
$for Person$
 Dear
 $if Gender="M"$
  Mr. $else$ Ms. $end$
 $Name: $,
$end$
+ Gender = F;
Person = (
 {Name = Smith; Gender = M;},
 {Name = Jones;}
)
= Dear Mr. Smith,
Dear Ms. Jones,
 
Can it adjust the case of properties? 
Intercalate can.
$for Person$
 Dear
 $if Gender="M"$
  Mr. $else$ Ms. $end$
 $CapName$,
$end$
+ CapName = Name(capitalize);
Gender = F;
Person = (
 {Name = smith; Gender = M;},
 {Name = jones;}
)
= Dear Mr. Smith,
Dear Ms. Jones,
 
Can it use properties as lookup tables? 
Intercalate can.
$for Person$
 Dear $Title$ $CapName$,
$end$
+ Title = GenderToTitle.Gender;
GenderToTitle = {
  M = Mr.;
  F = Ms.;
};
CapName = Name(capitalize);
Gender = F;
Person = (
 {Name = smith; Gender = M;},
 {Name = jones;}
)
= Dear Mr. Smith,
Dear Ms. Jones,
 
Can it redirect input and output on the fly? 
Intercalate can.
$for Person$
$write Name.doc$
$include Name.greeting$
 $Title$ $CapName$,
$end$

smith.greeting
Dear

jones.greeting
My dearest

+ Title = GenderToTitle.Gender;
GenderToTitle = {
  M = Mr.;
  F = Ms.;
};
CapName = Name(capitalize);
Gender = F;
Person = (
 {Name = smith; Gender = M;},
 {Name = jones;}
)
= smith.doc
Dear Mr. Smith,

jones.doc
My dearest Ms. Jones,

Can your mail-merge program be integrated into your Java application or servlet? Intercalate can. Take a look at our on-line demonstration of this kind of embedding.

Although you could use Intercalate for mail-merging, the real leverage comes about in more complex situations in which there are multiple outputs, not just one. Read on to see how the power of Intercalate can be brought to bear on these more demanding needs.
 
Alodar Systems