help-octave
[Top][All Lists]
Advanced

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

loading the functions automatically


From: Kamaraju S Kusumanchi
Subject: loading the functions automatically
Date: Mon, 18 Jun 2007 17:57:42 -0400
User-agent: KNode/0.10.4

Using Debian Etch, octave 2.9.9

Consider the following script

$cat even_odd.m
1;
function even_odd1(m)
  # use bitand instead of mod to figure out if a number is odd or even
  # if (mod(m, 2) == 1)
  if (bitand(m,1))
    printf("%d is odd\n", m)
  else
    printf("%d is even\n", m)
  endif
endfunction

n = 25
even_odd1(n)
n = 30
even_odd1(n)


I am able to run the script as

$octave -q
octave:1> even_odd
n =  25
25 is odd
n =  30
30 is even
octave:2> 

After that, I can do

octave:2> even_odd1(23)
23 is odd
octave:3> 

That is the function even_odd1 is loaded into the memory. Now if I go back
to even_odd.m and change the function even_odd1, then the changes are not
reflected back on the octave command line.

Say the new even_odd.m is

$cat even_odd.m
1;
function even_odd1(m)
  # use bitand instead of mod to figure out if a number is odd or even
  # if (mod(m, 2) == 1)
  if (bitand(m,1))
    printf("%d is odd\n", m)
  else
    printf("%d is even\n", m)
  endif
  printf("finished executing even_odd1\n");
endfunction

n = 25
even_odd1(n)
n = 30
even_odd1(n)



octave:3> even_odd1(23)
23 is odd

whereas it should print

octave:3> even_odd1(23)
23 is odd
finished executing even_odd1

What is happening is that octave is running the even_odd1 function that is
already in its memory without checking if the function has been updated or
not.

What is the best way to load the new even_odd1 function at the octave prompt
without rerunning the whole script again?

On this machine, I have

octave:7> val=ignore_function_time_stamp ()
val = system




thanks
raju

-- 
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/



reply via email to

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