octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #66617] structfun assumes output arguments for


From: Fernando
Subject: [Octave-bug-tracker] [bug #66617] structfun assumes output arguments for invoked command
Date: Sun, 5 Jan 2025 07:37:22 -0500 (EST)

Follow-up Comment #11, bug #66617 (group octave):

Thanks for the info, @lt1234. The problem with your solution is that the
number of outputs of a function is not always known a priori. E.g. this
function:

function varargout=ff2(x)
varargout={x,2*x};
end

returns two outputs, but nargout(@ff2) returns -1, which means Octave does not
know a priori the number of outputs.

Because of that, your solution throws an error in this case:

s = struct ("a", 1, "b", 4);
[a, b] = structfun (@ff2, s);
error: element number 2 undefined in return list


I updated the patch with some tests which have to do with that case. This is
attached here.

@lt1234, can you confirm if the patch fixes the issue in your case? (for
convinience, I also attach the file, structfun.m, resulting from applying the
patch).

(file #56743, file #56744)

    _______________________________________________________

Additional Item Attachment:

File name: structfun5.diff                Size: 2KiB
    <https://file.savannah.gnu.org/file/structfun5.diff?file_id=56743>

File name: structfun.m                    Size: 6KiB
    <https://file.savannah.gnu.org/file/structfun.m?file_id=56744>


    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-60bab5f4bb97079a4f50fd30c5633b2562628477.tar.gz


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66617>

_______________________________________________
Mensaje enviado vía Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature


reply via email to

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