Jump to content

Extension:WikiLambda/Creating Objects

From mediawiki.org

Create a function

[edit]

To create a new function for use in your own implementations and enable others to use it as well, follow these steps. New functions can be written in your preferred natural language.

  1. Go to the Special:CreateZObject function creation page.
  2. Name your function.
  3. Define your function's inputs:
    1. Add/remove input fields.
    2. Define each input type.
    3. Name each input.
  4. Define your function output type.
  5. Optionally, provide multilingual options for any of these fields:
    • Function name, function aliases, input labels.
  6. Publish your function.

Create a test

[edit]

To create tests for your function implementations to ensure they are working properly, follow these steps:

  1. Find a function on your wiki, or the function you created in the previous workflow.
  2. Navigate to the function page.
  3. Click the “+” link in the tests table.
  4. Click on "Select Function" under "Call".
    1. In the field under "Function", type in the name of the function you are testing and select the function when it shows up.
    2. Add values for the inputs in the respective fields.
  5. Click on "Select Function" under "Result Validation". In the field under "Function", type in the name of the function you want to use to check the result.
    • For a function whose output is String, this will be "String equality", for a function whose output is Boolean, this will be "Boolean equality".
    • Add the expected value in the given field (either "Second String" or "Second Boolean").
  6. Publish your updates.

Create an implementation

[edit]

Functions are brought to life in implementations created to suit your needs. Run, remix, and combine functions via implementations. We recommend creating and connecting a test before creating an implementation. To create an implementation, follow these steps:

  1. Find a function on your wiki.
  2. Navigate to the function page.
  3. Click the “+” link in the implementations table.
  4. You can create a new implementation in one of two ways:
    1. Code
      • Select the required programming language to write the function code.
      • Input your code.
    2. Composition:
      • Create a composition using existing functions.
  5. Publish your updates (after running a test by clicking the round arrow on the right of the box titled Tests).