497a965295fe7c3545a7f56b113872bed7560d37
[scilab.git] / scilab / modules / functions / help / en_US / deff.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) XXXX-2008 - INRIA
5  * Copyright (C) 2018 - Samuel GOUGEON
6  *
7  * Copyright (C) 2012 - 2016 - Scilab Enterprises
8  *
9  * This file is hereby licensed under the terms of the GNU GPL v2.0,
10  * pursuant to article 5.3.4 of the CeCILL v.2.1.
11  * This file was originally licensed under the terms of the CeCILL v2.1,
12  * and continues to be available under such terms.
13  * For more information, see the COPYING file which you should have received
14  * along with this program.
15  *
16  -->
17 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
18           xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
19           xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
20           xml:lang="en" xml:id="deff">
21     <refnamediv>
22         <refname>deff</refname>
23         <refpurpose>in-line definition of a function in Scilab language</refpurpose>
24     </refnamediv>
25     <refsynopsisdiv>
26         <title>Syntax</title>
27         <synopsis>deff('[s1, s2, ...] = newfunction(e1, e2, ...)',text)</synopsis>
28     </refsynopsisdiv>
29     <refsection>
30         <title>Arguments</title>
31         <variablelist>
32             <varlistentry>
33                 <term>e1, e2, ...</term>
34                 <listitem>
35                     <para>input variables.</para>
36                 </listitem>
37             </varlistentry>
38             <varlistentry>
39                 <term>s1, s2, ...</term>
40                 <listitem>
41                     <para>output variables.</para>
42                 </listitem>
43             </varlistentry>
44             <varlistentry>
45                 <term>text</term>
46                 <listitem>
47                     <para>a matrix of character strings.</para>
48                 </listitem>
49             </varlistentry>
50         </variablelist>
51     </refsection>
52     <refsection>
53         <title>Description</title>
54         <para>
55             <function>deff</function> can be used to define functions from sequences of instructions
56             written in text strings. The resulting function object has the same properties
57             of any other function defined in a text file and loaded with <function>exec</function>.
58         </para>
59         <warning>
60             Quotes included in instructions given in strings must be doubled to be protected.
61         </warning>
62     </refsection>
63     <refsection>
64         <title>Examples</title>
65         <programlisting role="example"><![CDATA[
66 deff('x = myplus(y,z)', 'x = y+z')
67 myplus(1,%i)
68
69 deff('[y, z] = mymacro(x)', ['y = 3*x+1'; 'z = a*x + x.^2'])
70 a = 3;
71 [u, v] = mymacro(2)
72  ]]></programlisting>
73     <screen><![CDATA[
74 --> deff('x = myplus(y,z)', 'x = y+z')
75 --> myplus(1,%i)
76  ans  =
77    1. + i
78
79 --> deff('[y, z] = mymacro(x)', ['y = 3*x+1'; 'z = a*x + x.^2'])
80 --> a = 3;
81 --> [u, v] = mymacro(2)
82  v  =
83    10.
84
85  u  =
86    7.
87 ]]></screen>
88     </refsection>
89     <refsection role="see also">
90         <title>See also</title>
91         <simplelist type="inline">
92             <member>
93                 <link linkend="function">function</link>
94             </member>
95             <member>
96                 <link linkend="exec">exec</link>
97             </member>
98             <member>
99                 <link linkend="getd">getd</link>
100             </member>
101             <member>
102                 <link linkend="genlib">genlib</link>
103             </member>
104             <member>
105                 <link linkend="jdeff">jdeff</link>
106             </member>
107             <member>
108                 <link linkend="jcompile">jcompile</link>
109             </member>
110         </simplelist>
111     </refsection>
112     <refsection role="history">
113         <title>History</title>
114         <revhistory>
115             <revision>
116                 <revnumber>6.0.0</revnumber>
117                 <revdescription>
118                    <itemizedlist>
119                      <listitem>
120                        The input option
121                        <ulink url="https://help.scilab.org/docs/5.5.2/en_US/deff.html">
122                          <varname>opt="c"|"p"|"n"</varname>
123                        </ulink> is no longer available.
124                      </listitem>
125                      <listitem>
126                         The defined <varname>newfunction</varname> is now of type 13 (instead of 11).
127                      </listitem>
128                   </itemizedlist>
129                 </revdescription>
130             </revision>
131         </revhistory>
132     </refsection>
133 </refentry>