help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple functions in a file


From: Etienne Grossmann
Subject: Re: Multiple functions in a file
Date: Sat, 11 Nov 2000 11:13:25 +0000
User-agent: WEMI/1.13.7 (Shimada) FLIM/1.13.2 (Kasanui) Emacs/20.7 (i386-debian-linux-gnu) (with unibyte mode)

  Hello,

From: Andy Adler <address@hidden>

#  Is it possible to put multiple function
#  definitions in a single *m file.

  In a script file (a file that does not start by a function
definition), yes. For example : 

======================================================================
address@hidden: cat > foo.m 
1;
function x=foo(y)
  x= 1+bar(y);
endfunction

function a=bar(b)
  a=b^2;
endfunction
address@hidden: fg
octave  (wd: Šþ)

octave:16> which foo
which: `foo' is the script file
/home/etienne/prog/octave/mylib/foo.m
octave:17> foo
warning: function `foo' defined within script file 
`/home/etienne/prog/octave/mylib/foo.m'
octave:18> which foo
foo is a user-defined function
octave:19> foo (3)
ans = 10
======================================================================

  Note that I first had to call 'foo' as a script so that the
functions get declared.

  To avoid the warning, you could name the script 'foo_decl_script' or
someting alike.

#  But I'd really like to be able to do this,
#  as I don't want people to bar to be accessible directly.

  I think 'bar' will always be visible.

  Hth,

  Etienne



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]