bugGNU Octave - Bugs: bug #49496, syntax error

 
 

bug #49496: syntax error

Submitter:  Michael Godfrey <godfrey>
Submitted:  Mon 31 Oct 2016 10:54:52 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Godfrey Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 01 Nov 2016 02:42:39 PM UTC, comment #3: 

Final comment: last night I was working on getting work
done, not thinking about Octave syntax. Now I realize that
the [min (di), max (di)] error came about due to an
overzealous script which applied the rule that a blank
should appear between function name and (.

Sorry about the confusion.

Michael Godfrey <godfrey>
Group Member
Mon 31 Oct 2016 11:25:28 PM UTC, comment #2: 

You are right.

I am not sure how long ago it was that this worked,
but I am pretty sure that it did. I was running some
quite old code.

However, it also does not work in Matlab.
Matlab's diagnostic is a bit more informative:


[min (di), max (di)]
Error using min
Not enough input arguments.
=================================

Anyhow, best to close the bug report.

Michael Godfrey <godfrey>
Group Member
Mon 31 Oct 2016 11:02:04 PM UTC, comment #1: 

This is not a bug, this is the usual confusion about spaces within an array literal.

When you create an array, any whitespace is treated as a separator between elements. Your example


## this:
>> [min ([1 2 3])]
error: ...
## is the same as this:
>> [min,  ([1 2 3])]
error: ...
## which is also the same as this
>> [min(), ([1 2 3])]
error: ...


This can't be fixed, you just have to remember to omit spaces when calling a function inside of an array context like this, or surround the entire thing with parentheses


>> [(min ([1 2 3]))]
ans =  1


Mike Miller <mtmiller>
Group Member
Mon 31 Oct 2016 10:54:52 PM UTC, original submission:  


octave:1> [min([1 2 3])]
ans =  1
octave:2> [min ([1 2 3])]
error: Invalid call to min.  Correct usage is:

 -- min (X)
 -- min (X, [], DIM)
 -- [W, IW] = min (X)
 -- min (X, Y)

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
octave:2> version
ans = 4.3.0+
octave:3>

Would be good to check if this error exists in current stable

Michael Godfrey <godfrey>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by godfrey (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-31 mtmiller StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code