Apogee v0.8.8 - Getting Started
  • Apogee v0.8.8 - Getting Started
  • Tutorials - Basics
    • Populating a Data Table
    • Data Views in a Data Table
    • Defining Functions
    • Folders and Scope
    • "Immutable" Values Gotcha
    • Debugging
    • Reusing Code
    • The Messenger, and Functional Programming
  • Tutorials - More Components
    • Configurable Form Components
      • Dynamic Form
      • Form Data Table
    • External Libraries and Controls
    • Custom Components
      • Custom Component
      • Custom Data Component
    • Folder Functions
    • Roll Your Own Components
  • Additional Apogee Videos
    • What is Apogee? An Overview
  • Additional Example Workspaces
    • The Grid and Spreadsheets
    • Combined Example
Powered by GitBook
On this page

Was this helpful?

  1. Tutorials - Basics

Defining Functions

This tutorial shows the different ways of defining functions

PreviousData Views in a Data TableNextFolders and Scope

Last updated 6 years ago

Was this helpful?

Example workspace:

The workspace linked above contains five tables (plus the notes table). Four of them contain formulas, each multiplying the elements of the other table by a factor of two, with alternate ways of defining the needed function.

  • plainValue - This data table contains a plain static value, an array of numbers.

  • derivedValue - This table uses the array map function to multiply each element of plainValue by two. The function called by map is defined inline.

  • alternateDerivedView - This table also uses the array map function to multiply each element of plainValue by two. Howeever, it defines the function called by map elsewhere. It puts it in the private code section of the table. The view dropdown shows the different sections of the table, including the data, the formula and the private code sections. The private code section allows you to put constants and functions accessed from your formula, to keep the code a little cleaner.

  • anotherAlternateDerivedView - This table also uses the array map function to multiply each element of plainValue by two. However, it uses an external function in the call to the array map function. See testFunction below.

  • testFunction - This is an external function, which is used by the data table anotherAlternateDerivedView. A function table can be created as you would create a data table, except you select Add Function instead of Add Data Table. A function table behaves like a normal javacript function when called by other tables.

There is one more way to make a function inside of Apogee, a folder function. We will cover that later.

Defining Functions Example Workspace