2020-9: Rise and Fall
Write a function that, given a right argument which is an integer scalar or vector, returns a 1 if the values of the right argument conform to the following pattern (0 otherwise):
- The elements increase or stay the same until the "apex" (highest value) is reached
- After the apex, any remaining values decrease or remain the same
💡 Hint: The Reverse function ⌽Y
and the Maximum function X⌈Y
combined with N-wise Reduction X f/ Y
or Scan f\ Y
can help with solving this problem.
Examples:
(your_function) 1 3 3 4 5 2 1
1
(your_function) 42
1
(your_function) 1 3 2 4
0
(your_function) 23 23 23
1
(your_function) ⍬ ⍝ empty vector
1
your_function ←
Solutions

