typestar

Functions in Igor Pro

A function declares what it returns before its name, and closes with End.

Function Area(Variable radius)
    return pi * radius^2
End

Function/S Describe(Variable radius)
    return "circle of area " + num2str(Area(radius))
End

Function/WAVE Ramp(Variable n)
    Make/O/N=(n)/D/FREE out = p
    return out
End

How it works

  1. Function with no type suffix returns a number.
  2. Function/S returns a string and Function/WAVE returns a wave reference.
  3. Parameters are declared with their types, in the parentheses or below.

Keywords and builtins used here

The run, in numbers

Lines
12
Characters to type
221
Tokens
53
Three-star pace
70 tpm

At the three-star pace of 70 tokens a minute, this run takes about 45 seconds.

Type this snippet

Step 2 of 3 in Variables & functions, step 6 of 18 in Language basics.

← Previous Next →

Functions in other languages