[Question]
  [
For our purposes, a trend is a contiguous subsequence of an array that falls into one of three categories:
* increasing, e.g. `[1,2,3,10,239]`
* decreasing, e.g. `[8,5,0,-3,-50]`
* stable, e.g. `[7,7,7,7]`
Note that `[1,1,2,3]` is not a valid trend. It can be broken up into a stable trend `[1,1]` and an increasing trend `[1,2,3]`. In the event an array has more than one trend, its trends will always overlap by one number.
## Task
Given an array of at least two integers in [any reasonable format](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods), output the trends of the array.
## Rules
* You must output the smallest possible number of trends. `[[1,1], [1,2], [2,3]]` is not valid output for `[1,1,2,3]`.
* You must output trends in the order they occur in the input.
* You may output in any format you like as long as we can tell the trends apart.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the code with the fewest bytes (in each language) wins.
* [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
## Test cases
| Input | Output |
| --- | --- |
| 
```
[1,2][1,2,1][1,1,2,3][1,-1,2,-2,3,-3][0,0,0,4,10,96,54,32,11,0,0,0][-55,-67,-80,5,5,5,9,9,9,9,14,20,25]
```
 | 
```
[[1,2]][[1,2], [2,1]][[1,1], [1,2,3]][[1,-1], [-1,2], [2,-2], [-2,3], [3,-3]][[0,0,0], [0,4,10,96], [96,54,32,11,0], [0,0,0]][[-55,-67,-80], [-80,5], [5,5,5], [5,9], [9,9,9,9], [9,14,20,25]]
```
 |
 
  
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), 30 bytes[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)
```
{(ùï©‚äèÀú+`)‚åæ‚àæ0‚àæ¬®=Àú‚äî+`¬ª‚â†‚üú¬´√ó1‚Üì-‚üú¬ªùï©}
```
[Run online!](https://mlochbaum.github.io/BQN/try.html#code=RuKGkHso8J2VqeKKj8ucK2Ap4oy+4oi+MOKIvsKoPcuc4oqUK2DCu+KJoOKfnMKrw5cx4oaTLeKfnMK78J2VqX0KCuKImOKAvzEg4qWKIEbCqCDin6gK4p+oMSwy4p+pCuKfqDEsMiwx4p+pCuKfqDEsMSwyLDPin6kK4p+oMSwtMSwyLC0yLDMsLTPin6kK4p+oMCwwLDAsNCwxMCw5Niw1NCwzMiwxMSwwLDAsMOKfqQrin6gtNTUsLTY3LC04MCw1LDUsNSw5LDksOSw5LDE0LDIwLDI14p+pCuKfqQ==)
| Code | Explanation | Example |
| --- | --- | --- |
| `x` | Argument | `‚ü® 1 1 2 4 ‚ü©` |
| `1‚Üì-‚üú¬ª` | Differences of adjacent arguments | `‚ü® 0 1 2 ‚ü©` |
| `√ó` | Sign of each value | `‚ü® 0 1 1 ‚ü©` |
| `¬ª‚â†‚üú¬´` | Mark starts of runs of equal adjacent values with a 1,  except the first. | `‚ü® 0 1 0 ‚ü©` |
| `+`` | Cumulative sum | `‚ü® 0 1 1 ‚ü©` |
| `‚äî` | Group indices by their value | `‚ü® ‚ü® 0 ‚ü© ‚ü® 1 2 ‚ü© ‚ü©` |
| `=Àú` | Self-equal; replace all values by 1's | `‚ü® ‚ü® 1 ‚ü© ‚ü® 1 1 ‚ü© ‚ü©` |
| `0‚àæ¬®` | Prepend a 0 to each group | `‚ü® ‚ü® 0 1 ‚ü© ‚ü® 0 1 1 ‚ü© ‚ü©` |
| `+`‚åæ‚àæ` | Cumulative sum under flattening the list | `‚ü® ‚ü® 0 1 ‚ü© ‚ü® 1 2 3 ‚ü© ‚ü©` |
| `ùï©‚äèÀú` | Index into the argument | `‚ü® ‚ü® 1 1 ‚ü© ‚ü® 1 2 4 ‚ü© ‚ü©` |
 
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
I·π†≈í…†1;√Ñr∆ù·ªã
```
[Try it online!](https://tio.run/##y0rNyan8/9/z4c4FRyedXGBofbil6Njch7u7/x9uPzrp4c4ZmpH//0dHG@oYxepwgSgdQwgDxDSGMHVBbF0gV0cXLGKgA4ImOoYGOpZmOqYmOsZAXYZgQQOQvK6pqY6umbmOroWBjikYWkKhoYmOkYGOkWlsLAA "Jelly ‚Äì Try It Online")
```
 ·π†            Take the signs of the
I             differences between adjacent elements.
  ≈í…†          Count the lengths of consecutive runs of equal signs,
    1;        prepend a 1,
      √Ñ       take the cumulative sums,
       r∆ù     get the inclusive ranges between each pair of adjacent values,
         ·ªã    and index each number in each range back into the input.
```
[Answer]
# [R](https://www.r-project.org), ~~83~~ ~~74~~ 73 bytes
*Edit: -9 bytes thanks to [@Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe).*
```
\(x,`?`=diff)Map(\(i,j)x[i:j],c(1,w<-which(!!?sign(?x))+1),c(w,sum(x|1)))
```
[Attempt This Online!](https://ato.pxeger.com/run?1=PU4xDoJAEOz9Bd1tnEvugEMwEmoLXyAmGMzJkWiMSKCw9Bc2aOKj_I2AQKbYmdmdyT5f1-atw09509z_rmNWI4mS8GC0ps3-wmJmkFO9Nct8h5RJVCteZSbNmGVFhTmeWVQTzSW1ywpFeWL1XRLRUPjQrAvZRLOBQU68U86keCd564CPpkAHF1Ig8KBcOG1c9qYYTrhS4N4C3BdQPYIB0oUtYKvxl6b5zx8)
Pretty straightforward:
1. Get signs of differences (identify trends).
2. Find starting positions of the trends.
3. Those (shifted by one) are also the ends of the trends.
4. `Map` over trends and extract them using `start:end`.
---
Alternative inspired by [Unrelated String's Jelly answer](https://codegolf.stackexchange.com/a/246412/55372):
### [R](https://www.r-project.org), ~~73~~ 71 bytes
*Edit: -2 bytes thanks to [@Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe).*
```
\(x)Map(\(i,j)x[i:j],head(w<-diffinv(rle(sign(diff(x)))$l)+1,-1),w[-1])
```
[Attempt This Online!](https://ato.pxeger.com/run?1=PY5LDoJAEET3nsNFd6xOZpBBNLp25QmABVFGhxhi_HIAb-EGTTyUtxF0NLXoqpeuTt_u--ZhZ8_T0Ur8mqdU8yLfUUoOJdeJm5QZNkW-ostUVs5aV51pvy3o4NYVdaAtMPe3PNAQzbgkojP2566WlqQRMPe8g_77Lg3_SbooLYH8oEKnEFphHMGEGLZ1_YHKr4gxkGgEiRXMR2MvHSJQCAz7X5rmO98)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 14 bytes
```
¬Ø¬±ƒ†vL0p¬¶2lv∆í·π°ƒ∞
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLCr8KxxKB2TDBwwqYybHbGkuG5ocSwIiwiIiwiWy01NSwtNjcsLTgwLDUsNSw1LDksOSw5LDksMTQsMjAsMjVdIl0=)
Port of Unrelated String's Jelly answer.
```
  ƒ†vL          # Get the lengths of the runs of identical...'
 ¬±             # Signs
¬Ø              # In the forward differences of the input
     0p¬¶       # Prepend a zero and get cumulative sums
         lv∆í   # Over runs of length...
        2      # 2
            ·π°  # Inclusive range
             ƒ∞ # Index those into the original array
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 60 bytes
```
->a,*w{a.each_cons(2){|x,y|(a!=a=x<=>y)&&w<<[x];w[-1]<<y};w}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5RR6u8OlEvNTE5Iz45P69Yw0izuqZCp7JGI1HRNtG2wsbWrlJTTa3cxia6Ita6PFrXMNbGprLWurz2f4FCWnS0oY6RjnFsLBecYwjjGCNzDHUMUTlGIH1AGqxKB2rKfwA "Ruby ‚Äì Try It Online")
### How it works
```
->a,*w{
```
Initialize `w` as an empty array, we will store the result there
```
a.each_cons(2)
```
Iterate on all pairs of consecutive elements of `a`
```
{|x,y|(a!=a=x<=>y)
```
Use `a` as a temporary variable to store the result of the last comparison. At the beginning its value will be different from anything else. On every iteration, check if the result of the comparison of the next 2 values is different from the previous result.
```
&&w<<[x]
```
If it's different, put the first of the two value in a new array inside of `w`.
```
;w[-1]<<y
```
Append the second value to the last array (continuation of sequence if the comparison result is the same, new array if it is different.)
```
};w}
```
Return `w` after the last iteration.
[Answer]
# [Perl 5](https://www.perl.org/), 107 bytes
```
sub{my@r;!@r?push@r,$l=[$_]:@$l<2||($_<=>$L)==($L<=>$$l[-2])?push@$l,$_:push@r,$l=[$L,$_]and$L=$_ for@_;@r}
```
[Try it online!](https://tio.run/##VZLPbtpAEMbP5Smm0RLsarb@A6bFjsMecitqLr0Z16LCTlGNcddYSgT02AfoI@ZF6M6uRYzW0n77zW@@mYPrXJbBmRXxuWl/HLYvQkbvhZzXbfNTSGRlnLAsDQUr7/zj0WLZXXzPFnYcW2xBkpUJ91Pb8KxEloX91oUy0lW1ZouYZVDspMgiIU/naKC0NQBI1Oehn0J8D4lWKUCKbxX0ejWEhIxrhKDxBfIIMtY1xsnkykf@RnON80s21zdRdGu0n@IinQl6Ls6mGExwrNbxtOl2mUYjsR1HjyvaVAnrZ/MgQD79hPyzi4E@s@54E/Rd9INuQg/UyxJPQjcZMdMzTbuRlwwz0j6oqQDbF4ttqhpZ/lzbsWBZ1NniabePb1lhCarbxq7lptoXN8NG6SEfT@l@/fuPSsNmWd0grLe1pbMg/60fCQWlNsxhtPs1ghBGXx@/weOXEb7TLIVjn4wGp0Hb5PCw2q/C8KHd1rmMQP2aBB3WebGp8jXLEjedm6JV79Tqfxpn2Rwjx3mSpL9//DBfJk7iyLCtVNPp/B8 "Perl 5 ‚Äì Try It Online")
[Answer]
# JavaScript, 84 bytes
-2 bytes from Arnauld, thanks!
```
f=([n,...a],d,s=[g=[]])=>1/n?f(a,D=Math.sign(a[0]-n,g.push(n)),d-D?[...s,g=[n]]:s):s
```
[Try it online!](https://tio.run/##dVBLbtswEN37FLMoIhIYqpJjJbED2pt02RMQBCLYtCzHIAVTDloEWXbXI7SX60Vc/qTaQEMuOJ/3hu/Nvn6t7frYdj3TZqPO5y0nQmOe57XEDVouGi6kpHxZftarLanxiX@t@11u20aTWhSSaWzy7mR3RFOKG/a0Eo5t0fG0lAtLF/b8OJmsjbY9tLo79RY4iAmIEqcS44tlinx8m2LmE@ZyZLFUoL8zLAuc32E1w1tHLEOxCABWVcju7pE9FFiFO0@3nOG0wGnlYHJUY079hZygJ4yJykB4WUOh9IWobiixUGMjmIWXBQMgguoITQK9gSTeJ1cWYtfDIuXCSRjqDfkguIrBPAyJ/mI4mkwu47bzrTl@qdc7QkKO0FLgS3ibAFyuwW0h7UO0jjw0j8qeDr65jXT6r9XV1o6s/KB00@@Ac544Q@XmxjGuTmKoV3X8TojxmvZBk/nfHLGXH4/68JiLDxBe4vjrqeJF0tGOOaj8YBoSTK0g@/PrRwYL9/7@mQFCWl3GlhmOq0AY0B76TNS3Tq17tYFPb9HiO312H7zTx/Nf "JavaScript (Node.js) ‚Äì Try It Online")
Explained
```
f = (
  [n, ...a],     // n: first item of array, a: remaining items
  d,              // d: previous difference
  s = [g = []]  // s: partial output, g: current group
) =>
  1 / n ?        // if n is a number, recurse, else return s
    f(           // call f() again
      a,         // remaining items
      D = Math.sign(a[0] - n, g.push(n)),  // assign new d to D
      d - D ?    // check if direction changes (sneakily push n to g)
        [...s, g = [n]] :  // if new direction, start a new group
        s,                 // else keep the same
    ) :
    s
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ 11 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
¬•.¬±Œ≥‚Ç¨g.¬•√º≈∏√®
```
-3 bytes porting [*@UnrelatedString*'s Jelly answer](https://codegolf.stackexchange.com/a/246412/52210).
[Try it online](https://tio.run/##yy9OTMpM/f//0FK9QxvPbX7UtCZd79DSw3uO7ji84v//aF1TUx1dM3MdXQsDHVMwtIRCQxMdIwMdI9NYAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfaXL/0NL9Q5tPLf5UdOadL1DSw/vObrj8Ir/Ov@jow11jGJ1QKSOIZgGsYzBLF0QUxfI09EFCRjogKCJjqGBjqWZjqmJjjFQiyFY0AAorWtqqqNrZq6ja2GgYwqGllBoaKJjZKBjZBobCwA).
**Original 14 bytes answer:**
```
√º2.Œ≥`.S}ŒµÀúŒπ`Œ∏¬™
```
[Try it online](https://tio.run/##yy9OTMpM/f//8B4jvXObE/SCa89tPT3n3M6EczsOrfr/P1rX1FRH18xcR9fCQMcUDC2h0NBEx8hAx8g0FgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/w3uM9M5tTtALrj239fScczsTzu04tOp/rc7/6GhDHaNYHRCpYwimQSxjMEsXxNQF8nR0QQIGOiBoomNooGNppmNqomMM1GIIFjQASuuamurompnr6FoY6JiCoSUUGproGBnoGJnGxgIA).
**Explanation:**
```
¬•           # Get the forward-differences of the (implicit) input-list
 .¬±         # Get the sign (-1 if <0; 0 if 0; 1 if >0) for each value
   Œ≥        # Split it into equal adjacent values
    ‚Ç¨g      # Get the length of each inner list
      .¬•    # Undelta with leading 0
        √º   # For each overlapping pair:
         ≈∏  #  Create an inclusive ranged list
          √® # (0-based) index those lists into the (implicit) input
            # (after which the resulting list of lists is output implicitly)
√º2          # Split the (implicit) input-list into overlapping pairs
  .Œ≥        # Adjacent group these pairs by:
    `       #  Pop and push both values in the pair to the stack
     .S     #  And compare them (-1 if a<b; 0 if a==b; 1 if a>b)
   }Œµ       # After the adjacent group-by: map over each list of pairs:
     Àú      #  Flatten the list
      Œπ     #  Uninterleave it into two parts ([a,b,c,d,e,f] ‚Üí [[a,c,e],[b,d,f]])
       `    #  Pop and push both lists to the stack
        Œ∏   #  Pop the second list and leave just its last value
         ¬™  #  Append it to the first list ([a,c,e,f])
            # (after which the resulting list of lists is output implicitly)
```
[Answer]
# TI-Basic, 65 [bytes](https://codegolf.meta.stackexchange.com/a/4764/98541)
```
Input A
tanh(99ŒîList( üA
augment(Ans,{9‚ÜíB
1‚ÜíI
For(J,1,N
If  üB(I)= üB(J
End
Disp seq( üA(X),X,I,J
J‚ÜíI
End
```
prints each sublist on a new line
* `ŒîList(` is a `diff` function
* `tanh(99X)` is a `sign` function for integers: `tanh(0)=0`, `tanh(99)=1` and `tanh(-99)=-1`
* we add a 9 at the end of `üB`, different than any value a diff can take, so that the last sublist is always printed
* `I` stores the index of the start of the current sublist
* if the signs are equal, we cut the `For` loop short with the `End`
* otherwise, the `End` is skipped, so we print the sublist from `I` to `J` and set `I` to `J`
[![demo](https://i.stack.imgur.com/hkGAWm.jpg)](https://i.stack.imgur.com/hkGAWm.jpg)
[Answer]
# [Haskell](https://www.haskell.org/), 95 bytes
```
(!)=compare
x#y=show x++' ':y
f(a:x@(b:c:t))|a!b==b!c=a#f x|1>0=a#(b#('|':f x))
f[x,y]=x#(y#"")
```
[Try it online!](https://tio.run/##bY/BioMwEIbveYpYF0zoBBKrbRWy7APsbY/iIdpKl21raV02gu/uOkkpu1TmMDP//2f4cjC3r/3xOI4s4LpuTxdz3RMb9vp2aH@oXS4jGuU9aZjJ7Rur8jrvOB9MUGldBbU2YUPtoF7lNLEqZNEQ5ZPCOWkKC32pbcj6cLHg48l8nvWuJfTy3X101/czfaENLRTE5YwGakZFfTWjCzTE5IF4tiVgJaAkZGtIE1hNx5UT5VNYpCmI9QbEVkLqKruXSiCWEKclGQsHXRLfgRZI61eFq8f0gnCKeASF68iK3QFj0NMA0t5JcfnH612M4YM/oO4g8uLgoP2QuRMe34@PP5TkFw "Haskell ‚Äì Try It Online")
A bit weird output: a string where *trends* are separated by `|` and elements are space separated.
**Alternatively**  
Output a list of lists for *111 bytes*.
```
f l=l?(l!2)
(#)=compare
(a:t@(b:c:r))!x|a#b==b#c=t!(x+1)|1>0=x:t!2
_!x=[x]
l?(h:t)=take h l:drop(h-1)l?t
_?x=[]
```
[Try it online!](https://tio.run/##XczBioMwGATge54iwR4S9g8kqem2gb/uexQp0VoU0yo2hxz67q6WvazM7ZthWv/qmxDm@U4DhoIHZgThmcB6eIx@agj3Lv7wytVuEoKlt88qxCqrMTKevrR467PC5CIz5MoSXlJJlpvWRYHR9w1taXC3aRh5K7UIRSTXYlmV88N3T7wNhI5T94x0R@/0osGUWwC9pRX3W5SryqUAuekUrMlBKzgdwOawXz71B9X/pbQW5OEb5FGB/eT0F52DUWBsSeZf "Haskell ‚Äì Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 15 bytes
```
¬Ø¬±ƒ†vL1p¬¶2lv∆í·π°‚Äπƒ∞
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLCr8KxxKB2TDFwwqYybHbGkuG5oeKAucSwIiwiIiwiWy01NSwtNjcsLTgwLDUsNSw1LDksOSw5LDksMTQsMjAsMjVdIl0=)
## How?
```
¬Ø¬±ƒ†vL1p¬¶2lv∆í·π°‚Äπƒ∞
¬Ø               # Deltas (consecutive differences) of (implicit) input
 ¬±              # Sign of each
  ƒ†             # Group consecutive identical items
   vL           # Length of each
     1p         # Prepend a one
       ¬¶        # Cumulative sums
        2lv∆í·π°   # For each overlapping pair, get an inclusive range between them
             ‚Äπ  # Decrement each
              ƒ∞ # Index each into the (implicit) input
```
[Answer]
# JavaScript (ES6), 90 bytes
```
f=(a,s,c=[],[v,...b]=a,x=[...c,v],q=Math.sign(b[0]-v))=>1/v?s-q?[x,...f(a,q)]:f(b,q,x):[c]
```
[Try it online!](https://tio.run/##bY1NDsIgFIT3ngSSeQi1@JegJ/AEhAVFqzWmtWJIb1@pcWczm5f5Zt7cffIxvJrnm9rufBnH2jCPiGCsg00QQlTOeAzG5jMgOfTm5N83EZtryyorHSXOzUEt0zFSf7TD1Knzk567fc0q9Bj43gY3hq6N3eMiHt2V1cwqFI7zxb8LNetPZDVLaEKUKWguIDGphJLYraFLrPKE@ppyJk5ag9Yb0FZCf7X7SZUoJAqdS@MH "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 75 bytes
```
\d+
*
L$`(?<=((_+)))((,(?<2>\2_+))+|(,(?!\1|\6)(_+))+|(,\1)+)\b
$1$&
_+
$.&
```
[Try it online!](https://tio.run/##K0otycxLNPz/PyZFm0uLy0clQcPexlZDI15bU1NTQ0MHyDOyizECcbVrQFzFGMOaGDNNDZhIjKGmtmZMEpeKoYoaV7w2l4qe2v//hjogaKJjaKBjaaZjaqJjbKRjCBE0BAA "Retina ‚Äì Try It Online") Only supports positive integers due to language limitations. Explanation:
```
\d+
*
```
Convert to unary.
```
(?<=((_+)))
```
For each trend starting just after a value (either the first value or the last value of the previous trend)...
```
((,(?<2>\2_+))+|(,(?!\1|\6)(_+))+|(,\1)+)\b
```
... match either a trend where the value increases each time, a trend where the value decreases each time, or a trend where the value doesn't change, ...
```
L$`
$1$&
```
... and output the matched trend preceded by the initial value.
```
_+
$.&
```
Convert to decimal.
[Answer]
# [Julia](http://julialang.org/), 62 bytes
```
!x=(a=1;~ =diff;findall(~[sign.(~x);9].!=0).|>i->x[a:(a=1+i)])
```
[Try it online!](https://tio.run/##LUtLDoIwEN1zirJr45S0QFUk5QaegLBoQjFjmmoADQvD1bFF5yUzb97n/nJo5LJt6aKp0bJeie5xGOoBfW@co2s74c1ndF1YXXVZqgXLPg3yZmnNJTYOyDq2DY@RIEFPRmt6h95OlCUkDBJN7Ns4erWzyZ5mnCxF9vOeI/rZeRoyDUmRJdb3Wysh75K4Qe43smJnPFIePuBREBBRghRQHUGVUISK3EURbK4U8OMJ@FmA2lH9IUvIBeSq@wI "Julia 1.0 ‚Äì Try It Online")
[Answer]
# [Python](https://www.python.org), 132 bytes
```
c=lambda a,b,*_:(a>b)-(a<b)
f=lambda h,*t,v=3:([[[h]],[]][c(h,*t)==v]+((r:=f(v=c(h,*t),*t))[0].insert(0,h)or r)if t else[[h]])[v>2:]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=NZBNbsMgEIXX8SmQV4M7RPgvTaySiyBU4dTISK5j2dRy971FN9m0N-hhepuC6-gJ5s0bAZ_4_B7eXXvtb7evN2fY8ffjIjr9Wr9oorHG5LkCfa4pA_1U08jcZy0mDmeRVyClbJVCqZS8QIipELN6ABgrYWAWWxgWlVztbT81owOOLb2OZKTWEEeabmrWe6icz1mlNpYfSwSJ4ziSKWZq3TFda3D56liwzHfIQsAxqMCU4-mAZYG5P5KuIfdjVpbIDo_IjhzLVadNaYEZx6xUUXjQeLaF2J7Y_TR01nW2byagVbTzvIsvu8WjNbPuYKG-G0bbOzCQLJT-w98_9A8)
# [Python](https://www.python.org), ~~138~~ 136 bytes
*-2 bytes thanks to @[Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)*
```
t=lambda a,b,*c:(a>b)-(a<b)
def f(x):
    i=j=0
    while-~i<len(x):
        k=t(*x[j:])
        while-~j<len(x)and t(*x[j:])==k:j+=1
        yield x[i:j+1];i=j
```
[Attempt This Online!](https://ato.pxeger.com/run?1=PVBBUsMgFF0np2CygvpxIE1qG4sXyWRBDExJkWbaqOnGtXdw043uPJC3EWh0_gy8_94D_uPjaziPu4O7XD6fR03XP--jsPKp7SSS0MLiscLyoSUUy21L0k5ppPFEqjQxohcsTV53xir6ZrZWuauQ7MWIF1PdVw3x3WzoZ4N0HfqXhdhX_Y3g3nY2ynZoqo0neHPvb5_n-TZIoCzL0ppD3sQVeNwDWkZEA6S-AxoIBqEK4Aw2KygLWPojPJLMy7Qsga7ugK4ZlLE2c_ECcgZ52aThQX04ogkZh8ztabBmtMapE47ZNZpC0uFonA-jsXqR1ocj5Dr032f-Ag)
[Answer]
# [MATLAB](https://www.gnu.org/software/octave/), 92 bytes
```
function t(m)
d=[1 find(diff(sign(diff(m))))+1 numel(m)];for i=2:numel(d)
m(d(i-1):d(i)),end
```
[Try it online!](https://tio.run/##JYgxDoAgDEV3TsHYRh1gxHgSw2AsNU2kJIpeH0n8y3vvl71ub2qNH92rFLUVMhpaVmdZlICEGW459LeMfYOz@uR09oozl8vK4sP/EJoMBDI5DB2IY1JqbXWjjx8 "Octave ‚Äì Try It Online")
]