Wikifunctions:Introduction
Functions are computer instructions that make calculations on the data you provide, and answer questions you have about them. For example, when you ask a voice assistant how many miles are in a kilometer, the voice assistant calls a function to calculate it for you.
Wikifunctions is an open source project that enables anyone to create functions and share them for others to use, remix, test, and learn from.
Use the following how-to guides to try out the basic features of Wikifunctions. We are looking forward to your feedback and contributions!
Evaluate a Function
You can try out community-contributed functions on Wikifunctions for yourself! Pick one from our library of functions, and give input values to discover the output.
Steps:
- Find a function on the Main page.
- Navigate to a function page.
- Enter the input values.
- Run the function.
Results:
- Was the output what you expected?
- Do you have corrections or feedback to report?
Create a Function
You can add your own functions to Wikifunctions! Create a new function for use in your own implementations and enable others to use it as well. New functions can be written in your preferred language.
Steps:
- Go to the function creation page.
- Name your function.
- Define your function's inputs:
- Add/remove input fields.
- Define each input type.
- Name each input.
- Define your function output type.
- Optionally, provide multilingual values for any of these fields:
- Function name, function aliases, input labels.
- Publish your function.
Results:
- Was the function successfully saved?
- Do you have corrections or feedback to report?
Edit a Function
You can contribute to Wikifunctions by editing its library of functions. Add or edit multilingual information to functions, and expand and alter the definitions of functions.
Steps:
- Find a function on the Main Page.
- Navigate to the function page.
- Click Edit source to see the edit options for this function.
- Optionally, modify the values of:
- Function name,
- Function aliases,
- Input list
- Add/remove input fields
- Edit input type
- Edit input labels
- Output type.
- Optionally, provide multilingual values for any of these fields:
- Function name
- Function aliases
- Input labels.
- Publish your updates.
Results:
- Were your edits successfully saved?
- Do you have corrections or feedback to report?
Create tests
You can create tests for your function implementations in Wikifunctions to ensure they are working properly.
Steps:
- Find a function on the Main Page or the function you created in the previous workflow.
- Navigate to the function page.
- Click the “ ” link in the tests table.
- Click on "Select Function" under "Call".
- In the field under "Function", type in the name of the function you are testing and select the function when it shows up.
- Add values for the inputs in the respective fields.
- 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").
- Publish your updates.
Results:
- Was the test successfully saved?
- Do you have corrections or feedback to report?
Create an implementation
Functions are brought to life in implementations created to suit your needs. Run, remix, and combine functions via implementations in Wikifunctions. See the section below to learn how to connect your implementation to functions. We recommend creating and connecting a test before creating an implementation. A more comprehensive guide to creating implementations is available at Wikifunctions:How to create implementations.
Steps:
- Find a function on the Main Page.
- Navigate to the function page.
- Click the “ ” link in the implementations table.
- You can create a new implementation in one of two ways:
- Code
- Select the required programming language to write the function code.
- Input your code.
- Composition:
- Create a composition using existing functions.
- Code
- Publish your updates (after running a test by clicking the round arrow on the right of the box titled Tests).
Results:
- Was the implementation successfully saved?
- Do you have corrections or feedback to report?
Connect an Implementation or Test to a Function
- Note: This feature is only available to Functioneers.
Connect tests and implementations to your function to see it come to life.
Steps:
- Find a function on the Main Page.
- Navigate to the function page.
- Select one or more tests, or one or more implementations.
- Click on the button “Connect”.
Results:
- Was the attach/detach state successfully changed?
- Do you have corrections or feedback to report?