g | x | w | all
Bytes Lang Time Link
046AWK250326T172915Zxrs
001EXA Language Size 8250321T234808Ztypecast
109SAKO250321T182319ZAcrimori
008Uiua231020T045700Zchunes
057Lua230520T021437Zbluswimm
004Nekomata + e230519T010946Zalephalp
017Julia230518T205354ZCzylabso
nanKamilalisp230518T181014ZKamila S
021Julia 0.6230202T183930ZAshlin H
008Stax230414T143937Zemirps
036Arturo230202T213710Zchunes
033Excel230202T201436ZJos Wool
nan230202T185345ZThe Thon
011Pip230202T171805ZDLosc
052Swift 4170920T222412ZAlexande
027Regex ECMAScript210402T053255ZDeadcode
005Pyt230201T015847ZKip the
043Rust221029T095150Zcorvus_1
006Pyth221029T071434Zhakr14
028Factor221029T015158Zchunes
004Vyxal221029T004339ZDialFros
085PHP171031T053640ZJo.
046Desmos210412T004920ZEthan Ch
013K ngn/k210327T005111Zcoltim
nanPxem210327T023248Zuser1004
033Factor210326T195609Zuser
016Add++180307T211251Zcaird co
033Haskell170920T164123ZLaikoni
056F#171103T232853ZJason Ha
033Ruby170920T171233ZSnack
019J171031T080946ZGalen Iv
013Pushy171030T204642ZFlipTack
028CasioBasic171006T064609Znumberma
003Jelly170920T153929ZMr. Xcod
007TIBasic170920T181935ZOki
055Excel VBA170923T232149ZTaylor R
029JavaScript ES7170920T160309ZArnauld
035Clojure170921T221239ZNikoNyrh
041Jq 1.5170921T212909Zjq170727
089Scheme170921T204551ZGenRince
012Pyth170921T193816ZStan Str
049Python 3170921T143852Zospahiu
021Octave170920T223150ZLuis Men
053Common Lisp170921T114644ZRenzo
026R170920T164255Zuser2390
0558th170920T211934ZChaos Ma
008RProgN 2170921T022456ZATaco
013APL170921T002018ZVyxal Bo
025Perl 6170920T155133ZRamillie
056C170920T160826ZSteadybo
060Java OpenJDK 8170920T163000ZOlivier
4418C# .NET Core170920T161246ZGrzegorz
006Japt170920T155612ZJustin M
035Python 2170920T185711ZDennis
040Python 3170920T180819ZDennis
036Clojure170920T181013ZMattPutn
062PowerShell170920T174708ZAdmBorkB
024Mathematica170920T173908ZMartin E
034Mathematica170920T173831Zuser6198
nanPerl 5170920T173541ZXcali
004Ohm v2170920T170452ZMr. Xcod
041Proton170920T160303Zhyperneu
006Pyth170920T155430ZMr. Xcod
009anyfix170920T164505Zhyperneu
007Pyth170920T162802ZSteven H
004Husk170920T155326ZErik the
036JavaScript ES6170920T160148ZNeil
065MATL170920T155320ZCinaski
054Python 3170920T154347ZLeaky Nu
078Java OpenJDK 8170920T155152ZRoberto
045Python 3170920T154513ZMr. Xcod
00505AB1E170920T153915ZEmigna

AWK, 46 bytes

{for(x=1;i++<NF-1;)($i-$(i+1))^2>1&&x=0}1,$0=x

Attempt This Online!

{for(x=1;          # default insignificant
i++<NF-1;)         # through elements of array
($i-$(i+1))^2>1    # if abs() >1
&&x=0              # set x to 0
}1,$0=x            # output 1 or 0

EXA Language - Size 8, 1 EXA

DATA 1 2 3 4 3; EDIT ME
MARK READ
SUBI F F T
SEEK -1
FJMP READ
SUBI T 1 T
FJMP READ
ADDI T 2 T
FJMP READ

Input is given through the DATA pseudo-instruction (multiple can be used if needed). Output is given through how the EXA halts:

Explanation:

This image can be imported into Redshift Player:

solution file

SAKO, 109 bytes

PODPROGRAM:F(*C,N)
CALKOWITE:N,I
STRUKTURA(N):C
W=0
*)A=ABS(C(I)-C(I-1))
W=W+A*A
POWTORZ:I=1(1)N
F()=W-N
WROC

I use here the fact that 1 = 0*0 = 1*1. (Programmatically, not mathematically)
Returns 0 if the array is insignificant or a positive value if it isn't.

For a more structured output F()=W-N can be changed to F()=SGN(1,W-N) for +7 bytes, and it will output only 1 when is significant.

Due to some hardships when handling arrays in SAKO function also takes the last index of array as input. May be invalid because of that. However creating a string parser to take input would be much too many bytes for a CodeGolf challenge.

Full programme version, 108 bytes

BLOK(9):C
CZYTAJ:*C
W=0
*1)A=ABS(C(ENT(I))-C(ENT(I-1)))
W=W+A*A
POWTORZ:I=1(1)9
DRUKUJ(9,0):W-N
STOP1
KONIEC

This isn't the main version despite the byte count because the length of the input array is hardcoded and cannot be changed.

Full programme version deluxe, 136 bytes

CALKOWITE:N,I
CZYTAJ:N
BLOK(9):C
STRUKTURA(N):C
CZYTAJ:*C
W=0
*1)A=ABS(C(I)-C(I-1))
W=W+A*A
POWTORZ:I=1(1)N
DRUKUJ(9,0):W-N
STOP1
KONIEC

This one also takes two inputs from STDIN:

  1. The last index of the array <=9
  2. The array itself

Uiua, 8 bytes

≅±.≡/-◫2

Try it!

≅±.≡/-◫2
      ◫2  # windows of length two
   ≡/-    # subtract second column from first (differences)
  .       # duplicate
 ±        # sign (pervasive across array)
≅         # do they match?

Lua, 57 bytes

for i=2,#arg do b=b or 1<(arg[i]-arg[i-1])^2 end print(b)

Try it online!

Outputs false if the array is insignificant, or true if it is not.

Nekomata + -e, 4 bytes

∆A2<

Attempt This Online!

∆A2<
∆       Differences
 A      Absolute value
  2<    Is less than 2?

Nekomata + -e, 4 bytes

∆:±=

A port of @Mr. Xcoder's Pyth answer.

Attempt This Online!

∆:±=
∆       Differences
 :      Duplicate
  ±     Sign
   =    Equal?

Julia, 17 bytes

!x=diff(x)⊆-1:1

Attempt This Online!

Kamilalisp, 31 bytes (APL385 SBCS)

$(∧?∘⌹‡⍡ 2 $(> 2)∘abs∘$(⌿⊙← -))

Attempt This Online!

Julia 0.6, 21 bytes

~x=all(diff(x).^2.<2)

Try it online!

-1 byte thanks to MarcMush: pass a single argument to all

Stax, 8 bytes

┘ε≡}◄ï╖Z

Run and debug it

Link includes all test cases.

Unpacked:

Stax, 10 bytes

:-{|a2<m:*

Run and debug it

:-          # pairwise differences/deltas
  {     m   # mapped by
   |a       # absolute value of n
     2<     # is less than 2
         :* # product of array (essentially all(a))

Arturo, 36 bytes

$[a][n:a\0every? a'x[2>abs n-x n:x]]

Try it

Excel, 35 33 bytes

=AND(ABS(DROP(ζ,1)-DROP(ζ,-1))<2)

2 bytes saved under the assumption that the input can be arbitrarily chosen so as to be a vertical vector.

Thunno, \$ 7 \log_{256}(96) \approx \$ 5.76 bytes

z[ZA2<P

Attempt This Online!

Outputs 0 for False and 1 for True.

Explanation

z[ZA2<P  # Implicit input
z[       # Differences of the input
  ZA     # Absolute value of each
    2<P  # Are they all less than 2?
         # Implicit output

Pip, 11 bytes

2>M:BAD_MPg

Attempt This Online!

Explanation

2>M:BAD_MPg
          g  ; List of command-line arguments
        MP   ; Map to each pair of adjacent elements:
     AD      ;  Absolute difference between
    B        ;  the second and
       _     ;  the first
  M:         ; Get the max of that list
2>           ; 1 (truthy) if the max is less than 2; 0 (falsey) otherwise

Swift 4, 52 bytes

{!zip($0.dropFirst(),$0).map(-).contains{1<abs($0)}}

Test suite:

let isInsignificant: (_ array: [Int]) -> Bool = {!zip($0.dropFirst(),$0).map(-).contains{1<abs($0)}}

let testcases: [(input: [Int], expected: Bool)] = [
    (input: [1, 2, 3, 4, 3, 4, 5, 5, 5, 4], expected:  true),
    (input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 8], expected:  true),
    (input: [3, 3, 3, 3, 3, 3, 3],          expected:  true),
    (input: [3, 4, 4, 4, 3, 3, 3, 4, 4, 4], expected:  true),
    (input: [1, 2, 3, 4],                   expected:  true),
    (input: [5, 4, 3, 2],                   expected:  true),
    (input: [1, 3, 5, 7, 9, 7, 5, 3, 1],    expected: false),
    (input: [1, 1, 1, 2, 3, 4, 5, 6, 19],   expected: false),
    (input: [3, 4, 5, 6, 7, 8, 7, 5],       expected: false),
    (input: [1, 2, 4, 10, 18, 10, 100],     expected: false),
    (input: [10, 20, 30, 30, 30],           expected: false),
]

for (caseNumber, testcase) in testcases.enumerated() {
    let actual = isInsignificant(testcase.input)
    assert(actual == testcase.expected,
        "Testcase #\(caseNumber) \(testcase.input) failed. Got \(actual), but expected \(testcase.expected)!")
    print("Testcase #\(caseNumber) passed!")
}
```

Regex (ECMAScript), 27 bytes

^(x(x*)(,(?=\2x?x?\b)|$))*$

Try it online!

Input is a list of positive unary numbers separated by ,. Each one is a string of xs whose length represents the number.

^
(
    x(x*)         # \2 = this element - 1
    # Assert that either the next element is in the range \2 to \2+2 inclusive,
    # or that we've reached the end and there are no more elements.
    (
        ,         # Skip to the next element
        (?=       # look ahead to the next element to make the following assertion:
            \2    # subtract \2 from it
            x?x?  # subtract any number from 0 to 2 from it
            \b    # assert that we matched the exact number
        )
    |
        $
    )
)*
$

Regex (ECMAScript), 21 bytes

\b(x+)(xx+,|,xx+)\1\b

Try it online!

Returns a non-match if the array is insignificant, and a match otherwise (i.e., its boolean result is inverted).

If this solution were converted to match=true logic, it would be ^(?!.*\b(x+)(xx+,|,xx+)\1\b) (28 bytes).

           # No anchor; can match starting anywhere
\b         # Assert word boundary, i.e. either the start of the string before
           # an "x", a position after an "x" and before a ",", a position
           # after a "," and before an "x", or the end of the string after an
           # "x".
(x+)       # \1 = any substring of "x"es
(
    xx+,   # 2 or more "x"es followed by ","
|          # or
    ,xx+   # "," followed by 2 or more "x"es
)
\1         # Match what was captured in \1
\b         # Assert word boundary

Pyt, 5 bytes

₋Å2<Π

Try it online!

₋           implicit input; get differences
 Å          Åbsolute value
  2<        is each difference less than 2?
    Π       product; implicit print

Rust, 43 bytes

|a|a.windows(2).all(|s|(s[1]-s[0]).abs()<2)

Try it online!

A fn(&[i8])->bool.

Pyth, 6 bytes

._MI.+

Test suite

Explanation:
._MI.+  | Full code
._MI.+Q | with implicit variables
--------+------------------------------------
    .+Q | Differences of the input
   I    | Is it invariant over:
._M     |  Replace each element with its sign

Factor, 28 bytes

[ [ - [-1,1]? ] monotonic? ]

Try it online!

monotonic? is a combinator that tests if a quotation returns true for every pair of adjacent elements in a sequence.

Vyxal, 5 4 bytes

¯vṅA

Try it Online!

¯vṅA
¯    # delta (consecutive diff)
 vṅ  # abs(a) ≤ 1
   A # all truthy?

-1 thx to @Sʨɠɠan

PHP, 85 bytes

function a($p){$r=1;foreach($p as$k=>$q)if($p[$k+1]&&abs($p[$k+1]-$q)>1)$r=0;echo$r;}

Try it online!

It can probably be golfed some more, but it's a start.

Desmos, 46 bytes

\left\{max(abs(n[2,...,n.length]-n))<2\right\}

View on Desmos!

This is a rare case where I think using \left\{\right\} is more efficient than not.

K (ngn/k), 15 13 bytes

-2 bytes from @ngn's improvements

&/2>#'!'1_-':

Try it online!

Pxem, Filename: 40 bytes + Content: 0 bytes = 40 bytes.

Usage

Input is from STDIN; output from STDOUT. First positive integer N for input represents number of items in list. Then integers c1, c2, ..., cN represents each item of the list. Each input has to be separated by one or more s.

An output of Y represents truthy, and no output falsey.

Input example

List [1, 2, 3, 4, 3, 4, 5, 5, 5, 4] is:

10
1 2 3 4 3 4 5 5 5 4

With comments

XX.z
.a._\001.-.cXX.z # push N; decrement it
.a._.tXX.z # push c1; heap<-c1
.a.w\001.-XX.z # while N!=0; do N--
  .a._.c.m.-\001.xXX.z # push ci; if abs(ci-heap); then
    .a.dXX.z # exit
  .a.aXX.z # fi
  .a.tXX.z # heap=ci
.a.c.aXX.z # done
.aY.oXX.z # putchar o
.a

Link

Try it online!

Factor, 48 33 bytes

Saved 15 bytes thanks to @chunes!

[ dup rest v- vabs supremum 2 < ]

Try it online! (results are at the bottom)

dup rest makes a copy of the inputted sequence without the first element. v- subtracts that from the original sequence (\$a_n-a_{n-1}\$). Then vabs gets the absolute values of that. supremum finds the maximum value in the sequence, and 2 < makes sure it's 0 or 1.

Add++, 16 bytes

L,vbUÑ_€|2ª>

Try it online!

How it works

L,		; Create a lambda function
		; Example argument: 	    ['[1 2 3 4 3 4 5 5 5 4]']
	vbU	; Evaluate as list; STACK = [1 2 3 4 3 4 5 5 5 4]
	Ñ_	; Deltas;	    STACK = [1 1 1 -1 1 1 0 0 -1]
	€|	; Absolute values;  STACK = [1 1 1 1 1 1 0 0 1]
	2ª>	; All less than 2;  STACK = [1]

Haskell, 34 33 bytes

all((<2).abs).(zipWith(-)=<<tail)

Try it online! -1 byte thanks to @user1472751


The point-free solution is one two again only one byte (thanks to -1 byte from @Dennis) shorter than the recursive approach:

f(a:b:r)=2>(a-b)^2&&f(b:r)
f _=1>0

Try it online!

F#, 56 bytes

let f a=Seq.forall(fun(x,y)->abs(x-y)<2)(Seq.pairwise a)

Ruby, 36 35 33 bytes

->b,*a{a.all?{|x|(b-(b=x))**2<2}}

Takes the input array as individual arguments.

-1 byte thanks to MegaTom, -2 bytes thanks to Jordan.

Try it online!

J, 20 19 bytes

i=.[:*/2>[:|2&(-/\)

I defined it as a verb, which adds 3 bytes to the total length.

Explanation

2&(-/\) finds the difference between two consecutive elements
| takes the absolute value
[: caps the fork so that the result is propagated onwards
2> finds if the values are smaller than 2
*/ calculates the product of all the elements, so yields 1 only if all are 1s
[: caps the fork so that the result is propagated onwards

Example:

   i 1 3 5 7 9 7 5 3 1  
0

Try it online

Pushy, 13 bytes

$2d-|v.;Og2<#

Try it online!

                 \ Implicit: Input on stack
$      ;         \ While there are items left on stack:
 2d-|            \   Get the absolute difference of the last two integers
     v           \   Send this to the second stack
      .          \   Pop the last item 

        O        \ Go to the second stack (list of differences)
         g       \ Sort ascendingly (largest item last)
          2<#    \ Check if it is smaller than 2 (print 1/0 accordingly)

Casio-Basic, 28 bytes

judge(max(abs(⊿list(n)))<2

It's nice that the fx-CP400 has a built-in for cumulative differences. Not so nice that you need to use judge to force it to check whether the resulting value is less than 2.

27 bytes for the function ( is two bytes), +1 to enter n in the argument list.

Jelly, 3 bytes

IỊẠ

Try it online!

How?

Just the perfect challenge for Jelly.

IỊẠ   Full program.

I     Increments; Get the difference between consecutive elements.
 Ị    Insignificant; return abs(number) ≤ 1.
  Ạ   All; returns 1 if all the elements are truthy, 0 otherwise.

TI-Basic, 6 7 bytes

prod(2>abs(ΔList(Ans

or, 5 bytes if errors count as valid return value (returns ERR:ARGUMENT if insignificant, else ERR:DOMAIN)

augment(sin⁻¹(ΔList(Ans

Excel VBA, 55 Bytes

Anonymous VBE immediate window function that takes input from range [1:1] and outputs to the VBE immediate window

[2:2]="=IfError(If(B1=0,0,ABS(B1-A1)),0)":?[Max(2:2)>1]

JavaScript (ES7), 33 29 bytes

Saved 4 bytes thanks to @JohanKarlsson

a=>!a.some(v=>(a-(a=v))**2>1)

How?

When coerced to Number, arrays of at least two elements are evaluated to NaN. By re-using the input a as the variable holding the previous value, the first iteration of some() always results in ([v0, v1, ...] - a[0]) ** 2 = NaN, no matter the value of a[0]. So, the first test is always falsy and the actual comparisons start at the 2nd iteration, just as they're meant to.

Test cases

let f =

(a,p)=>!a.some(v=>(p-(p=v))**2>1)

console.log(f([1, 2, 3, 4, 3, 4, 5, 5, 5, 4])) // true
console.log(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 8])) // true
console.log(f([3, 3, 3, 3, 3, 3, 3]         )) // true
console.log(f([3, 4, 4, 4, 3, 3, 3, 4, 4, 4])) // true
console.log(f([1, 2, 3, 4]                  )) // true
console.log(f([5, 4, 3, 2]                  )) // true
console.log(f([1, 3, 5, 7, 9, 7, 5, 3, 1]   )) // false
console.log(f([1, 1, 1, 2, 3, 4, 5, 6, 19]  )) // false
console.log(f([3, 4, 5, 6, 7, 8, 7, 5]      )) // false
console.log(f([1, 2, 4, 10, 18, 10, 100]    )) // false
console.log(f([10, 20, 30, 30, 30]          )) // false

Clojure, 35 bytes

#(every? #{-1 0 1}(map -(rest %)%))

How neat is that?

Jq 1.5, 42 41 bytes

all(keys[1:][]as$i|.[$i]-.[$i-1]|.*.;.<2)

Explained

all(                   # true if all values from
    keys[1:][] as $i   # scanning input indices starting at second element
  | .[$i]-.[$i-1]      # calculate differences between successive elements
  | .*.                # square the difference
; . < 2                # are < 2
)

Sample Run

$ jq -Mc 'all(keys[1:][]as$i|.[$i]-.[$i-1]|.*.;.<2)' data.json
true
true
true
true
true
true
false
false
false
false
false

$ echo -n 'all(keys[1:][]as$i|.[$i]-.[$i-1]|.*.;.<2)' | wc -c
  41

Scheme - 89 bytes

(define (f n) (if (not (empty? n)) (and (<= (abs (- (cadr n) (car n))) 1) (f (cdr n))) 1)

Pyth, 15 12 bytes

Works pretty simply. T or 10 as a boolean is True

V.+Q=&T<N2)T

Explanation:

V.+Q        In the difference map of the input...
    =&T<N2) T = T && the current item is less than 2, and close the loop
T           Print J

Test Suite

Python 3, 49 bytes

lambda l:all(abs(j-i)<=1 for i,j in zip(l,l[1:]))

Octave, 21 bytes

@(x)all(diff(x).^2<2)

Anonymous function that inputs a numeric vector and ouputs 1 if insignificant or 0 otherwise.

Try it online!

Common Lisp, 53 bytes

(lambda(a)(every(lambda(x y)(< -2(- x y)2))a(cdr a)))

Try it online!

R, 30 26 bytes

cat(all(diff(scan())^2<2))

Try it online!

8th, 66 49 55 bytes

Code

1 >r ( n:- abs dup 1 > if rdrop 0 >r then ) a:y drop r>

SED (Stack Effect Diagram) is: a -- f

Explanation

This code leaves 1 on TOS if array is insignificant, otherwise it leaves 0. Here the ungolfed version:

1 >r                                           \ suppose array is insignificant
( n:- n:abs dup 1 n:> if rdrop 0 >r then ) a:y \ compute corresponding (absolute) differences and check if difference is > 1
drop r>                                        \ clean stack and put result on TOS

We could immediately exit from loop with break when array is significant, but in this case we waste 6 bytes.

RProgN 2, 8 bytes

{-â2<}á*

Explained

{-â2<}á*
{    }á     # Fold the input by the function
 -          # Subtract, get the difference.
  â         # Absolute
   2<       # Is less than 2.
       *    # Get the product, 1 for truthy, 0 for falsey.

Try it online!

APL, 13 bytes

{×/(|2-/⍵)<2}

First APL answer \o/

Note: I am a bot owned by Hyper Neutrino. I exist mainly for chat testing.

Explanation

{×/(|2-/⍵)<2}
{           }  Function; right argument is ⍵
   (     )     Bracketed Expression
       /       Reduce
     2         Every pair (two elements) of
        ⍵      ⍵
      -        Using subtraction
    |          Magnitude (Absolute Value)
          <2   For each element, is it less than two?
  /            Reduce over
 ×             Multiplication (Product) (All)

Perl 6, 25 bytes

{?(2>all(.[]Z-.skip)>-2)}

Try it online!

This should be pretty readable. The only less obvious thing here is that the zip operator Z will stop zipping when the shorter list is exhausted (we remove the first element of the list at the right) and that the empty subscript .[], so called Zen slice, gives the whole list. .skip returns the list without the first element.

C, 61 56 bytes

Thanks to @scottinet for saving five bytes!

r;f(a,n)int*a;{for(r=1;--n;r=(*a-*++a)/2?0:r);return r;}

Try it online!

C (gcc), 47 bytes

r;f(a,n)int*a;{for(r=1;--n;r=(*a-*++a)/2?0:r);}

Try it online!

Java (OpenJDK 8), 60 bytes

a->{int r=1,p=a[0];for(int i:a)r|=(r=p-(p=i))*r;return r<2;}

Try it online!

C# (.NET Core), 51 45 44 + 18 bytes

-1 byte thanks to Jeppe Stig Nielsen

a=>a.Zip(a.Skip(1),(x,y)=>x-y).All(x=>x*x<4)

Byte count also includes:

using System.Linq;

Try it online!

Explanation:

a =>                      // Take an array of integers as input
    a.Zip(                // Combine each element with corresponding one from:
        a.Skip(1),        //     the input array without first element
        (x, y) => x - y   //     get their difference
    )
    .All(x => x * x < 4)  // Check if all differences are less than 2
                          // (We only care about 0 and 1, and so happens that when they're squared, it works like Abs! Magic!)

Japt, 6 bytes

äa e<2

Try it online!

Explanation

ä        Get all pairs of elements
 a       Take absolute difference of each pair
         This results in the deltas of the array
   e     Check if every element...
    <2   Is less than 2

Python 2, 35 bytes

x=input()
while-2<x.pop(0)-x[0]<2:1

Exists with status code 1 for insignificant arrays, with status code 0 otherwise.

Try it online!

Python 3, 40 bytes

f=lambda n,*t:t==()or-2<n-t[0]<=1==f(*t)

Try it online!

Clojure, 36 bytes

#(every? #{-1 0 1}(map - %(rest %)))

Try it online!

PowerShell, 62 bytes

param($a)$l=$a[0];($a|?{$_-$l-in1..-1;$l=$_}).count-eq$a.count

Try it online!

PowerShell doesn't have a .map or .some or similar command, so here we're individually checking each delta.

We take input $a and set $l equal to the first element. Then we loop through $a and take out each element where |?{...} the difference $_-$l is -in the range 1,0,-1. We then set $l equal to the current element. So now we have a collection of elements where the delta between their previous neighbor is 1. We take the .count of that and check whether it's -equal to the .count of the array as a whole. If it is, then every delta is 1 or less, so it's an insignificant array. That Boolean result is left on the pipeline, and output is implicit.

Mathematica, 24 bytes

Max@Abs@Differences@#<2&

Mathematica, 34 bytes

Differences@#~MatchQ~{(1|0|-1)..}&

Explanation

                                 & (* Function *)
Differences                        (* which takes the consecutive differences*)
           @#                      (* of the input list *)
             ~MatchQ~              (* and returns whether it matches *)
                     {(1|0|-1)..}  (* a list consisting of one or more 1s, 0s, or -1s *)

Perl 5, 38 + 2 (-ap) = 40 bytes

$_&&=abs$i-$F[-1]<2while($i=pop@F)&&@F

Try it online!

Ohm v2, 4 bytes

Δ2<Å

Try it online!

How?

Δ2<Å   ~ Full program.

Δ      ~ Absolute deltas.
 2<    ~ Is smaller than 2?
   Å   ~ Check if all elements are truthy.

Proton, 41 bytes

a=>all(-2<a[i]-a[i+1]<2for i:0..len(a)-1)

Try it online!

-16 bytes thanks to Mr. Xcoder
-2 bytes
-6 bytes thanks to Mr. Xcoder

Pyth, 6 bytes

._MI.+

Verify all the test cases.


Pyth, 8 bytes

.A<R2aVt

Try it online!

Explanation

._MI.+   Full program.

    .+   Deltas.
   I     Is invariant under...
._M      Mapping with Sign. 0 if n == 0, -1 if n < 0, 1 if n > 0.

.A<R2aVt    Full program.

      Vt    Vectorize function, applied on the input zipped with the tail of the input.
     a      Absolute difference.
  <R2       For each, check if it is smaller than 2.
.A          All.

anyfix, 9 bytes

I€A€2<»/&

Try it online!

I€A€2<»/&  Main Link
I          Deltas
 €         For each element
  A        Take its absolute value
   €  »    For each element
    2<     Is it less than two?
       /   Reduce over
        &  Logical AND

This is mostly a port of the 05AB1E solution except terrible because anyfix doesn't have autovectorization and other cool things

Pyth, 7 bytes

._I#I.+

Test Suite

Returns true/false.

Explanation:

     .+ Deltas, returns differences between consecutive values.
._      Signum, returns the sign of a number (1, 0, or -1).  Note that this should
             be equal to the input for insignificant arrays.
  I     Tests if it is equal to the input...
   #    For each in the input, and filter out those that aren't...
    I   And make sure none have been filtered out.

Husk, 4 bytes

ΛεẊ-

Try it online!

Explanation:

ΛεẊ- 2-function composition
Λ    (x -> y):f -> [x]:x -> TNum: Check if f returns a truthy result for all elements of x
 ε    f: TNum:x -> TNum: Check if abs(x) <= 1 (shamelessly stolen from Jelly)
  Ẋ   x: (x -> x -> y):f -> [x]:x -> [y]: reduce each overlapping pair of x by f
   -   f: TNum:x -> TNum:y -> TNum: y - x

JavaScript (ES6), 37 36 bytes

(a,u)=>!a.some(e=>(e-=(u=e))>1|e<-1)

Edit: Saved 1 byte by stealing @Arnauld's trick.

MATL, 6 5 bytes

d|2<A

-1 byte thanks to Giuseppe

Try it online! or Verify all test-cases

Python 3, 54 bytes

2 bytes thanks to Jonathan Frech.

lambda a:all(-2<a[i]-a[i+1]<2for i in range(len(a)-1))

Try it online!

Java (OpenJDK 8), 78 bytes

a->{int p=0,i=1;for(;i<a.length;p+=Math.abs(a[i]-a[i++-1])>1?1:0);return p<1;}

Try it online!

Python 3, 45 bytes

lambda k:all(-2<x-y<2for x,y in zip(k,k[1:]))

Try it online! or Try the test suite.

Thanks to Jonathan Frech for -2 bytes.

05AB1E, 5 bytes

¥Ä2‹P

Try it online!

Explanation

¥        # calculate deltas
 Ä       # absolute values
  2‹     # smaller than 2
    P    # product