|
From: | anonymous |
Subject: | [Octave-bug-tracker] [bug #61199] Input validation for nchoosek |
Date: | Tue, 21 Sep 2021 16:51:52 -0400 (EDT) |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0 |
URL: <https://savannah.gnu.org/bugs/?61199> Summary: Input validation for nchoosek Project: GNU Octave Submitted by: None Submitted on: Tue 21 Sep 2021 08:51:51 PM UTC Category: Octave Function Severity: 3 - Normal Priority: 5 - Normal Item Group: Other Status: None Assigned to: None Originator Name: Originator Email: Open/Closed: Open Release: 6.3.0 Discussion Lock: Any Operating System: Any _______________________________________________________ Details: The nchoosek function currently does not accept character vectors (strings) though that is perfectly valid mathematically. To achieve that requires only one line of input validation to be changed: Change this: if (nargin != 2 || ! (isreal (k) && isscalar (k)) || ! (isnumeric (v) && isvector (v))) print_usage (); endif to this, removing "isnumeric(v)": if (nargin != 2 || ! (isreal (k) && isscalar (k)) || ! isvector (v)) print_usage (); endif Then this can be achieved: octave:7> nchoosek ('A':'E', 3) ans = ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?61199> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |