USING: kernel sequences grouping math.order make ; IN: updown ! Removes adjacent equal element. ! Example: { 1 1 1 2 2 1 } -> { 1 2 1 } : tighten ( seq -- seq ) [ { } ] [ [ [ dup 2 [ first2 = [ drop ] [ , ] if ] 2each ] [ last , ] bi ] { } make ] if-empty ; ! Returns t if the sequence increases and then descends. ! Example: { 1 2 3 2 1 } : updown? ( seq -- ? ) 2 [ first2 <=> ] map tighten { +lt+ +gt+ } sequence= ;