

examplelist:=
Hold(
{
  {40!,
"Simple factorial of a number.
"
  },
  {D(x)Sin(x),
"Taking the derivative of a function (the derivative of Sin(x) with
respect to x in this case).
"
  },
  {Taylor(x,0,5)Sin(x),
"Expanding a function into a taylor series.
"
  },
  {Integrate(x,a,b)Sin(x),
"Integrate a function.
"
  },
  {Solve(a+x*y==z,x),
"Solve a function for a variable.
"
  },
  {Limit(x,0) Sin(x)/x,
"Take a limit.
"
  },
  {Subst(x,Cos(a)) x+x,
"Substitute an expression with another in the main expression.
"
  },
  {Expand((1+x)^3),
"Expand into a polynomial.
"
  },
  {2^40,
"Big numbers.
"
  },
  {1<<40,
"Bitwise operations
"
  },
  {1 .. 4,
"Generating a list of numbers.
"
  },
  {a:b:c:{},
"Generating a list of items.
"
  },
  {[Local(x);x:={a,b,c};Sin(x)^2;],
"Threading: Sin(..)^2 will be performed on all elements of the list
passed in.
"
  },
  {[Local(list);list:={a,b,c,d,e,f}; list[2 .. 4];],
"Selecting a sublist from a list.
"
  },
  {Permutations({a,b,c}),
"Generate all permutations of a list.
"
  },
  {VarList(a+b*x),
"Show all variables that occur in an expression.
"
  },
  {TrigSimpCombine(Cos(a)*Cos(a)+Sin(a)*Sin(a)),
"Convert factors between trigonometric functions to addition of
trigonometric functions.
"
  }
}
);
exampleindex:=0;

Example():=
[
  exampleindex++;
  If (exampleindex>Length(examplelist),exampleindex:=1);

  Local(example);
  example:=examplelist[exampleindex];
  WriteString("Current example : ");
  Write(example[1]);WriteString(";");NewLine();
  NewLine();
  WriteString(example[2]);
  NewLine();
  Eval(example[1]);
];


