[top][index]
search for:

hold -- hold something in a holder expression

hold x -- embeds it argument x in a list of class Holder.

It might be useful for displaying an integer in factored form, for example, because the usual algebraic operations are available for Expressions, but no simplification occurs.

i1 : (hold 2)^5 * (hold 3)^3 * (hold 5) * (hold 11)^2

      5 3    2
o1 = 2 3 5*11

o1 : Product

Here is example of a little function that expresses rational numbers as Egyptian fractions using hold.

i2 : egyptian = method();
i3 : egyptian QQ := x -> (
         if x == 0 then 0
         else (
              n := ceiling(1/x);
              hold(1/n) + egyptian(x - 1/n) 
              ));
i4 : egyptian(30/31)

      1     1     1      1        1           1
o4 = (-) + (-) + (-) + (---) + (-----) + (---------)
      2     3     8     107     15922     633759288

o4 : Sum

Class of returned value: Holder -- the class of all holder expressionsCode:

     -- ../../../Macaulay2/m2/expressions.m2:1128
     hold = x -> new Holder from {x}

[top][index]
search for: