REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: function

function  spec  vars  body

Defines a user function with local words.

Arguments:

spec [block!] - Optional help info followed by arg words (and optional type and string)

vars [block!] - List of words that are local to the function

body [block!] - The body block of the function

See also:

func   does   has   make   use   function!   function?   return   exit  

Description

function is identical to func but includes a block in which you can name words considered local to the function.

average: function [block] [total] [
    total: 0
    foreach number block [total: number + total]
    total / (length? block)
]
print average [1 10 12.34]
7.78


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin