mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.12.0.3
This commit is contained in:
56
help/define
56
help/define
@@ -30,17 +30,17 @@ DESCRIPTION
|
||||
For example, suppose a function f and a global variable A have been
|
||||
defined by:
|
||||
|
||||
define f(x) = (x = 3);
|
||||
global mat A[3];
|
||||
; define f(x) = (x = 3);
|
||||
; global mat A[3];
|
||||
|
||||
If g() is a function that evaluates to 2:
|
||||
|
||||
f(A[g()]);
|
||||
; f(A[g()]);
|
||||
|
||||
assigns the value of A[2] to the parameter x and then assigns the
|
||||
value 3 to x:
|
||||
|
||||
f(`A[g()]);
|
||||
; f(`A[g()]);
|
||||
|
||||
has essentially the effect of assigning A[2] as an lvalue to x and
|
||||
then assigning the value 3 to A[2]. (Very old versions of calc
|
||||
@@ -79,7 +79,7 @@ DESCRIPTION
|
||||
|
||||
If the expr is omitted from an expression definition, as in:
|
||||
|
||||
define h() = ;
|
||||
; define h() = ;
|
||||
|
||||
any call to the function will evaluate the arguments and return the
|
||||
null value.
|
||||
@@ -105,11 +105,11 @@ DESCRIPTION
|
||||
|
||||
After fname has been defined, the definition may be removed by the command:
|
||||
|
||||
undefine fname
|
||||
; undefine fname
|
||||
|
||||
The definitions of all user-defined functions may be removed by:
|
||||
|
||||
undefine *
|
||||
; undefine *
|
||||
|
||||
If bit 0 of config("resource_debug") is set and the define command is
|
||||
at interactive level, a message saying that fname has been defined
|
||||
@@ -120,8 +120,8 @@ DESCRIPTION
|
||||
The identifiers used for the parameters in a function definition do
|
||||
not form part of the completed definition. For example,
|
||||
|
||||
define f(a,b) = a + b;
|
||||
define g(alpha, beta) = alpha + beta;
|
||||
; define f(a,b) = a + b;
|
||||
; define g(alpha, beta) = alpha + beta;
|
||||
|
||||
result in identical code for the functions f, g.
|
||||
|
||||
@@ -129,8 +129,8 @@ DESCRIPTION
|
||||
function are displayed on completion of its definition, parameters
|
||||
being specified by names used in the definition. For example:
|
||||
|
||||
> config("trace", 8),
|
||||
> define f(a,b) = a + b
|
||||
; config("trace", 8),
|
||||
; define f(a,b) = a + b
|
||||
0: PARAMADDR a
|
||||
2: PARAMADDR b
|
||||
4: ADD
|
||||
@@ -140,7 +140,7 @@ DESCRIPTION
|
||||
The opcodes may also be displayed later using the show opcodes command;
|
||||
parameters will be specified by indices instead of by names. For example:
|
||||
|
||||
> show opco f
|
||||
; show opco f
|
||||
0: PARAMADDR 0
|
||||
2: PARAMADDR 1
|
||||
4: ADD
|
||||
@@ -168,19 +168,19 @@ DESCRIPTION
|
||||
EXAMPLE
|
||||
; define f(a,b) = 2*a + b;
|
||||
; define g(alpha, beta)
|
||||
>> {
|
||||
>> local a, pi2;
|
||||
>>
|
||||
>> pi2 = 2 * pi();
|
||||
>> a = sin(alpha % pi2);
|
||||
>> if (a > 0.0) {
|
||||
>> return a*beta;
|
||||
>> }
|
||||
>> if (beta > 0.0) {
|
||||
>> a *= cos(-beta % pi2);
|
||||
>> }
|
||||
>> return a;
|
||||
>> }
|
||||
;; {
|
||||
;; local a, pi2;
|
||||
;;
|
||||
;; pi2 = 2 * pi();
|
||||
;; a = sin(alpha % pi2);
|
||||
;; if (a > 0.0) {
|
||||
;; return a*beta;
|
||||
;; }
|
||||
;; if (beta > 0.0) {
|
||||
;; a *= cos(-beta % pi2);
|
||||
;; }
|
||||
;; return a;
|
||||
;; }
|
||||
|
||||
LIMITS
|
||||
The number of arguments in a function-call cannot exceed 100.
|
||||
@@ -191,7 +191,7 @@ LIBRARY
|
||||
SEE ALSO
|
||||
param, variable, undefine, show
|
||||
|
||||
## Copyright (C) 2000 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
## Copyright (C) 2000-2006 David I. Bell, Landon Curt Noll and Ernest Bowen
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -207,8 +207,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: define,v 29.4 2006/05/07 07:25:46 chongo Exp $
|
||||
## @(#) $Revision: 29.5 $
|
||||
## @(#) $Id: define,v 29.5 2006/06/10 12:28:10 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/define,v $
|
||||
##
|
||||
##
|
||||
|
Reference in New Issue
Block a user