From octave-maintainers-request at bevo dot che dot wisc dot edu Tue Dec 31 16:07:46 2002 Subject: Re: f(end) feature? From: Paul Kienzle To: "John W. Eaton" Cc: octave-maintainers at bevo dot che dot wisc dot edu Date: Tue, 31 Dec 2002 17:07:43 -0500 On Tue, Dec 31, 2002 at 03:47:02PM -0600, John W. Eaton wrote: > On 31-Dec-2002, Paul Kienzle wrote: > > | So I guess the following is out of the question: > | > | function y = head(x) > | y = x(1:min(3,end)); > | end > > Sorry, that's not what I intended, and it's not actually prevented by > the previous patch, but min(3,end) would return -1, so you would not > get the result you expect. The following patch should help (I think). > > With it and the previous patch: > > octave:1> function y = head (x) y = x(1:min(3,end)); end > octave:2> x = [1,2,3,4] > x = > > 1 2 3 4 > > octave:3> head (x) > ans = > > 1 2 3 > > and > > octave:1> min (1,end) > error: __end__: internal error > error: evaluating argument list element number 2 > > > Is that better? I'm impressed! I still haven't figured out how you've done it. Maybe one day I'll give up and peek at the code. - Paul