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

Commonmark migration
Source Link

#MATL, 4 bytes

MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 d % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a)>0))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

#MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 d % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a)>0))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 d % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a)>0))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

edited body
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

#MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 dAd  % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a>0a)>0))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

#MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 dA % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a>0)))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

#MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 d  % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a)>0))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

added 50 characters in body
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63

#MATL, 54 bytes

d0>dAd0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 dA % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0. With `A`, makewhich sureis thata therefalsy arevalue noin zeroes.MATL

Implicitly displays a truthy 1 or falsy 0. This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a>0)))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

#MATL, 5 bytes

d0>dA

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 dA % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0. With `A`, make sure that there are no zeroes.

Implicitly displays a truthy 1 or falsy 0. This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a>0))))

#MATL, 4 bytes

d0>d

Explanation:

d % Implicitly take input. Take difference between each element
 0> % Check whether diff's are positive. Should result in [0 1 0 1 ...] pattern.
 dA % Again take the difference. Any consecutive rises or falls results in a 
 % difference of 0, which is a falsy value in MATL

This is my first MATL entry, so I wonder how much improvement there can be from this naive port from my MATLAB/Octave attempt (which would be @(a)all(diff(diff(a>0)))). Note that the all is not necessary because any zero makes an array false, so there's no A in the MATL port.

deleted 5 characters in body
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63
Loading
Post Undeleted by mbomb007, Luis Mendo, miles
Post Deleted by Sanchises
Post Undeleted by Sanchises
added 5 characters in body
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63
Loading
Post Deleted by Sanchises
Source Link
Sanchises
  • 9.5k
  • 1
  • 37
  • 63
Loading

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