Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Related, but not identical tips for MATLAB tips for MATLAB.

A little known and little used feature of Octave is that most builtin functions can be called without parentheses, in which case they will treat whatever follows it as a string (as long as it doesn't contain spaces). If it contains spaces you need quotation marks. This can frequently be used to save a byte or two when using disp. All the following work, and gives the same result:

disp('Hello')
disp Hello
disp"Hello"

If you have spaces, then you must have the quotation marks:

disp('Hello, World!')
disp"Hello, World!"

Other, less useful examples include:

nnz PPCG
ans = 4
size PPCG
ans = 1 4
str2num 12
ans = 12

Related, but not identical tips for MATLAB.

A little known and little used feature of Octave is that most builtin functions can be called without parentheses, in which case they will treat whatever follows it as a string (as long as it doesn't contain spaces). If it contains spaces you need quotation marks. This can frequently be used to save a byte or two when using disp. All the following work, and gives the same result:

disp('Hello')
disp Hello
disp"Hello"

If you have spaces, then you must have the quotation marks:

disp('Hello, World!')
disp"Hello, World!"

Other, less useful examples include:

nnz PPCG
ans = 4
size PPCG
ans = 1 4
str2num 12
ans = 12

Related, but not identical tips for MATLAB.

A little known and little used feature of Octave is that most builtin functions can be called without parentheses, in which case they will treat whatever follows it as a string (as long as it doesn't contain spaces). If it contains spaces you need quotation marks. This can frequently be used to save a byte or two when using disp. All the following work, and gives the same result:

disp('Hello')
disp Hello
disp"Hello"

If you have spaces, then you must have the quotation marks:

disp('Hello, World!')
disp"Hello, World!"

Other, less useful examples include:

nnz PPCG
ans = 4
size PPCG
ans = 1 4
str2num 12
ans = 12
Source Link
Stewie Griffin
  • 46.8k
  • 16
  • 137
  • 304

Related, but not identical tips for MATLAB.

A little known and little used feature of Octave is that most builtin functions can be called without parentheses, in which case they will treat whatever follows it as a string (as long as it doesn't contain spaces). If it contains spaces you need quotation marks. This can frequently be used to save a byte or two when using disp. All the following work, and gives the same result:

disp('Hello')
disp Hello
disp"Hello"

If you have spaces, then you must have the quotation marks:

disp('Hello, World!')
disp"Hello, World!"

Other, less useful examples include:

nnz PPCG
ans = 4
size PPCG
ans = 1 4
str2num 12
ans = 12

AltStyle によって変換されたページ (->オリジナル) /