Log in

Help for /print


Usage:  /print math_expression

/print provides a way to evaluate mathematical expressions from within Lily. It 
supports typical unary and binary operators, a few constants, and a library of 
basic math functions. It also understands operator precedence and supports 
parentheses to control the order of operations. The meaning of the operators 
generally mirrors those in Python, but only numeric values are returned. 
Strings, booleans, and other more complex data types are not supported.

Unary operators supported are:

  +  -  ~  not

Binary operators supported are:

  +   -   *  /   //  %    **
  <<  >>  &  |   ^   and  or
  <   <=  >  >=  ==  !=     

Constants supported are:

  e  pi

Functions supported are:

  abs     acos   acosh      asin   asinh  atan     athan2 
  atanh   ceil   copysign   cos    cosh   degrees  erf    
  exp     expm1  factorial  floor  gamma  gcd      hypot  
  lgamma  log    log1p      log2   log10  pow      radians
  round   sin    sinh       sqrt   tan    tanh     trunc  

As an example, you can confirm that the cosine of pi/4 is equal to 1/sqrt(2) by 
writing:

/print cos(pi/4) == 1/sqrt(2)
 => 1                        

The result of 1 means the == operator returned true.