FN: Your Function Shortcut

FN: Your Function Shortcut

Ever wish you could give your custom calculations a nickname and call on them whenever you needed them? Meet FN, your trusty function shortcut! This command lets you effortlessly access the custom functions you've defined using DEF FN, making your code more concise, readable, and oh-so-convenient!

Syntax

FN <function name>(<argument>)

Where: - <function name>: The single letter (A-Z) you used to name your custom function with DEF FN. - <argument>: The value you want to pass to the function for calculation.

Applications

The FN command is indispensable when:

  • You've defined custom functions using DEF FN and want to use them in your code.
  • You want to avoid repeating complex calculations multiple times in your program.
  • You want to improve the readability of your code by giving your functions meaningful names.

Code Examples

1. Calling a Custom Function:

10 DEF FNC(X) = X * (X + 1) / 2 :rem Define a function for triangular numbers
20 PRINT FNC(5)                 :rem Output: 15 
30 PRINT FNC(10)                :rem Output: 55

This example first defines a function FNC to calculate triangular numbers, then uses FN to call the function with different arguments.

2. Nested Function Calls:

10 DEF FNA(X) = X * X          :rem Square function
20 DEF FNB(Y) = 3 * Y + 1      :rem Linear function
30 Z = FNA(FNB(2))             :rem Calculate FNA(FNB(2)) 
40 PRINT Z                     :rem Output: 49

This demonstrates how FN can be used to nest function calls, where the output of one function becomes the input of another.

FN in the Wild: The Formulaic Composer

Imagine you're writing a program to generate musical notes. You could use DEF FN to define functions for different scales or chord progressions, then use FN to easily create melodies based on those formulas.

Don't repeat yourself! With the FN command, you can give your custom functions a name and a life of their own, making them easy to call upon whenever you need them. It's like having a team of specialists ready to perform complex calculations at your request. So embrace the power of FN and let your functions do the heavy lifting in your code!

Important Note: Remember that FN can only be used to call functions defined using DEF FN.


Privacy Policy

Let's be honest, we collect some data. But we promise not to sell it, we'll mostly use it to improve our service. You can read the nitty-gritty details below, but be warned, it uses big words that lawyers like (we don't judge).

By using our service, you agree to this privacy policy. This disclaimer strikes a balance between lightheartedness and informing users that they should still read the full privacy policy if they choose.