Symbolic function

Last updated 3 months ago

A bit more interesting example is a symbolic function:

function := ${ 2 * x + x * y }
printl "Calculating df/dx of ".concat( function.to_s() )
printl function.diff(${ x })
‚Äč
#=> Calculating df/dx of 2 * x + x * y
#=> 2 + y

This example would be clearer after reading all the documentation, but we can understand something as well.

  • You can define local variables without the need of declaring their types, and assignments use the convention of :=

    function := ${ 2 * x + x * y }
  • You can create symbolic functions just enclosing them between ${}

    ${ 2 * x + x * y }
  • You program by invoking methods to objects

    printl "Calculating df/dx of ".concat( function.to_s() )
    ...
    printl function.diff(${ x })
  • Method calls are identified by the two parenthesis at the end of the name

    function.to_s()