Documentation / LearningLemur

  • Demos
  • Visit our website
  • Contact us
  • MathType

    • Wiris Quizzes

      • Learning Lemur

        • CalcMe

          • MathPlayer

            • Store FAQ

              • VPAT for the electronic documentation

                • MathFlow

                  • BF FAQ

                    • Miscellaneous

                      • Wiris Integrations

                        • Home
                        • Learning Lemur
                        • Basic guide to Learning Lemur
                        • Using advanced logic
                        • Glossary of commands
                        • Glossary of commands

                        Programming functions

                        Reading time: 2min

                        This section introduces the foundational programming constructs, which are crucial for building sophisticated and adaptive logicals within LearningLemur. These functions allow you to control the flow of your code, generate random values, work with collections of data like sets and lists, and perform logical checks. 

                        The functionalities covered include:

                        • Commands like if, else, and else_if allow you to execute specific blocks of code based on whether certain conditions are met.
                        • The for statement enables repetitive execution of code for a defined number of iterations or over a range, and while executes code as long as a condition holds true.
                        • The random command is vital for creating dynamic content by generating unpredictable numbers or selecting random elements.
                        • Functions such as erase (to remove elements), max and min (to find extreme values), set (to create and manage unique collections), sort (to order data), and split (to divide strings) help you prepare and process data within your logicals.
                        • Commands like belongs? allow you to verify if an element is part of a set.

                        Functions

                        belongs?

                        Given an element and a list or a vector, returns true if the element belongs to the list or vector, and false otherwise.

                        belongs?(Element, List | Vector)
                         
                         

                        constant_list

                        Given an integer n and an element x, constructs a list with the element x repeated n times.

                        constant_list(Integer, Element)
                         
                         

                        else

                        Usual programming command. It should be preceded by an if. Executes the next block of code if the condition in the if statement was not hold.

                         
                         

                        else_if

                        Usual programming command. It should be preceded by an if. Executes the next block of code if the condition in the if statement was not hold and the current one is true.

                         
                         

                        for

                        Usual programming command. Write easily a loop that needs to be run a specific number of times.

                         
                         

                        is?

                        Given an object and a domain D, returns true if the object is of type D, and false otherwise.

                        is?(Object, Domain)
                         
                         

                        length

                        Given an object, returns its length.

                        length(List | Vector | Range | Rule)
                         
                         

                        list

                        Given an object, transforms it into a list.

                        list(Vector | Range | Permutation | Polygonal | Point | Frequency_sample_of)
                         
                         

                        maximum

                        Given a set of real numbers x1,...,xn, returns the maximum max{x1,...,xn}.

                        Given a list or vector, returns the maximum of its elements.

                        max(Real, ..., Real)
                        max(List | Vector | Range)
                         
                         

                        minimum

                        Given a set of real numbers x1,...,xn, returns the minimum min{x1,...,xn}.

                        Given a list or vector, returns the minimum of its elements.

                        min(Real, ..., Real)
                        min(List | Vector | Range)
                         
                         

                        null?

                        Given an object, returns true if it is null, and false otherwise.

                        null?(Object)
                         
                         

                        prepend

                        Given a list or a vector and an element, adds the element at the beginning of the list or vector, increasing its size.

                        prepend(List | Vector, Element)
                         
                         

                        random

                        Given an integer n, returns a random integer number in the interval [0,n) (if n is positive) or (n,0] (if n is negative).

                        Given a real x, returns a random real number in the interval [0,x) (if x is positive) or (x,0] (if x is negative).

                        Given two integers numbers a and b, returns a random integer in the interval [a,b].

                        Given two real numbers a and b, returns a random real number in the interval [a,b].

                        random(Integer)
                        random(Real)
                        random(Integer, Integer)
                        random(Real, Real)
                         
                         

                        repeat

                        Usual programming command. Executes the next block of code until the condition holds.

                         
                         

                        sort

                        Sorts a list, range or vector in ascending order.

                         
                         

                        subset?

                        Given two list or vectors A and B, returns true if the A is a subset of B, and false otherwise.

                        subset?(List | Vector, List | Vector)
                         
                         

                        where

                        Specifies a condition that needs to be hold. Works together with the function in.

                         
                         

                        while

                        Usual programming command. Executes the next block of code until the condition does not satisfy.

                         
                         

                        with

                        Specifies the range of an iterator.

                         
                         

                         

                         

                         

                        Was this article helpful?

                        Yes
                        No
                        Give feedback about this article

                        Related Articles

                        • Functions
                        • Structure Editor
                        • Taylor series

                        Programming functions

                        Functions belongs? constant_list else else_if for is? length list maximum minimum null? prepend random repeat sort subset? where while with

                        Making people’s STEM work more meaningful

                        MathType

                        • MathType for Office Tools
                        • MathType for Mac
                        • MathType for Microsoft 365
                        • MathType for Google Workspace
                        • MathType for LMS
                        • MathType for XML Editors
                        • Arabic notation
                        • Our products accessibility
                        • MathType is online

                        WirisQuizzes

                        Learning Lemur

                        Solutions for Education

                        • Blackboard Learn
                        • Brightspace by D2L
                        • Canvas
                        • Google Classroom
                        • Moodle
                        • Schoology

                        Solutions for Publishing Houses

                        Solutions for Technical Writers

                        Solutions for Chemistry

                        Integrations

                        • HTML Editors
                        • MathType in WordPress

                        Pricing

                        Company

                        Careers

                        Blog

                        Contact Us

                        Buy Now

                        Plugin Downloads

                        © Wiris 2025

                        • Cookie Settings
                        • Cookie Policy
                        • Terms of Use
                        • Privacy Policy / GDPR
                        • Student Data Privacy
                        • Compliance
                        • Powered by Helpjuice
                        Expand