~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to man/eng/functions/function.xml

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
 
2
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
 
3
<MAN>
 
4
  <LANGUAGE>eng</LANGUAGE>
 
5
  <TITLE>function</TITLE>
 
6
  <TYPE>Scilab keyword</TYPE>
 
7
  <DATE>April 1993</DATE>
 
8
  <SHORT_DESCRIPTION name="function"> opens a function definition</SHORT_DESCRIPTION>
 
9
  <SHORT_DESCRIPTION name="endfunction"> closes a function definition</SHORT_DESCRIPTION>
 
10
  <DESCRIPTION>
 
11
    <VERBATIM>
 
12
<![CDATA[
 
13
function <lhs_arguments>=<function_name><rhs_arguments>
 
14
<statements>
 
15
endfunction
 
16
   ]]>
 
17
    </VERBATIM>
 
18
    <P>
 
19
    Where
 
20
  </P>
 
21
    <DESCRIPTION_INDENT>
 
22
      <DESCRIPTION_ITEM label="&lt;function_name&gt;">
 
23
        <SP>stands for the name of the function</SP>
 
24
      </DESCRIPTION_ITEM>
 
25
      <DESCRIPTION_ITEM label="&lt;rhs_arguments&gt;">
 
26
        <SP>stands for the input argument list. It may be</SP>
 
27
      </DESCRIPTION_ITEM>
 
28
      <DESCRIPTION_ITEM label="-">
 
29
        <SP>a comma separated sequence of variable names enclosed in parenthesis, like  <VERB>(x1,...,xm)</VERB>. Last variable name can be the key word <VERB>varargin</VERB> (see varargin)</SP>
 
30
      </DESCRIPTION_ITEM>
 
31
      <DESCRIPTION_ITEM label="-">
 
32
        <SP>the sequence <VERB>()</VERB> or nothing,if the function has no input argument.</SP>
 
33
      </DESCRIPTION_ITEM>
 
34
      <DESCRIPTION_ITEM label="&lt;lhs_arguments&gt;">
 
35
        <SP>stands for the output argument list. It may be</SP>
 
36
      </DESCRIPTION_ITEM>
 
37
      <DESCRIPTION_ITEM label="-">
 
38
        <SP>a comma separated sequence of variable names enclosed in brackets, like  <VERB>[y1,...,yn]</VERB>. Last variable name can be the key word <VERB>varargout</VERB> (see varargout)</SP>
 
39
      </DESCRIPTION_ITEM>
 
40
      <DESCRIPTION_ITEM label="-">
 
41
        <SP>the sequence <VERB>[]</VERB> ,if the function has no input argument. In this case the syntax may also be:  <VERB>function &lt;function_name&gt;&lt;rhs_arguments&gt;</VERB></SP>
 
42
      </DESCRIPTION_ITEM>
 
43
      <DESCRIPTION_ITEM label="&lt;statements&gt;">
 
44
        <SP>stands for a set of scilab instructions (statements)  This syntax may be used to define function (see functions) inline or in a script file (see exec). For compatibility with old Scilab versions, functions defined in a script file containing only function definitions can be &quot;loaded&quot; into Scilab using the <VERB>getf</VERB> function.</SP>
 
45
      </DESCRIPTION_ITEM>
 
46
    </DESCRIPTION_INDENT>
 
47
    <P>
 
48
    The <VERB>function &lt;lhs_arguments&gt;=&lt;function_name&gt;&lt;rhs_arguments&gt;</VERB>
 
49
    sequence cannot be split over several lines. This sequence can be
 
50
    followed by statements in the same line if a comma of semi column is
 
51
    added at its end.</P>
 
52
    <P>
 
53
    function definitions can be nested</P>
 
54
  </DESCRIPTION>
 
55
  <EXAMPLE>
 
56
<![CDATA[
 
57
//inline definition (see function)
 
58
function [x,y]=myfct(a,b)
 
59
x=a+b
 
60
y=a-b
 
61
endfunction
 
62
 
 
63
[x,y]=myfct(3,2)
 
64
 
 
65
//a one line function definition
 
66
function y=sq(x),y=x^2,endfunction
 
67
 
 
68
sq(3)
 
69
 
 
70
//nested functions definition
 
71
function y=foo(x)
 
72
a=sin(x)
 
73
function y=sq(x), y=x^2,endfunction
 
74
y=sq(a)+1
 
75
endfunction
 
76
 
 
77
foo(%pi/3)
 
78
 
 
79
 
 
80
// definition in an script file (see exec)
 
81
exec SCI/macros/elem/asin.sci;
 
82
 
 
83
 
 
84
 ]]>
 
85
  </EXAMPLE>
 
86
  <SEE_ALSO>
 
87
    <SEE_ALSO_ITEM>
 
88
      <LINK>functions</LINK>
 
89
    </SEE_ALSO_ITEM>
 
90
    <SEE_ALSO_ITEM>
 
91
      <LINK>exec</LINK>
 
92
    </SEE_ALSO_ITEM>
 
93
    <SEE_ALSO_ITEM>
 
94
      <LINK>getf</LINK>
 
95
    </SEE_ALSO_ITEM>
 
96
  </SEE_ALSO>
 
97
</MAN>