| Bytes | Lang | Time | Link |
|---|---|---|---|
| 029 | Julia 0.6 | 230914T182335Z | Ashlin H |
| 087 | Go | 230914T202700Z | bigyihsu |
| 025 | APL Dyalog Unicode | 230829T184136Z | boltcapt |
| 7515 | Nibbles | 230830T154739Z | Dominic |
| 060 | janet | 230828T201431Z | krzych |
| 008 | Vyxal | 230721T110030Z | emanresu |
| 008 | Thunno 2 | 230721T063547Z | The Thon |
| 014 | Pip xp | 220116T051010Z | DLosc |
| 031 | R | 170509T125048Z | djhurio |
| 050 | Python 3 | 220113T193937Z | Alan Bag |
| 017 | Ly | 220115T080853Z | cnamejj |
| 044 | Factor | 220114T040929Z | chunes |
| 017 | GolfScript | 200126T142851Z | user8505 |
| 012 | Japt | 170519T161429Z | Shaggy |
| 008 | Husk | 170825T155150Z | Zgarb |
| 039 | JavaScript ES6 | 170509T061910Z | Shaggy |
| 066 | Scala | 170510T130906Z | Tamoghna |
| 035 | Ruby | 170509T094403Z | G B |
| 065 | C | 170509T101000Z | Khaled.K |
| 027 | Awk | 170511T045322Z | muru |
| 037 | Mathematica | 170509T044639Z | Greg Mar |
| 039 | Mathematica | 170510T033404Z | user6198 |
| nan | ><> | 170510T131643Z | Aaron |
| 011 | Alice | 170509T182122Z | Martin E |
| 126 | C# | 170509T065138Z | MetaColo |
| 035 | R | 170509T175247Z | user1159 |
| 036 | Retina | 170509T095223Z | Neil |
| 085 | Java 7 | 170509T074744Z | Kevin Cr |
| 015 | Röda | 170509T185753Z | fergusq |
| 029 | Haskell | 170509T145303Z | user4686 |
| 061 | Bash | 170509T170223Z | Max Mikh |
| 043 | Clojure | 170509T142147Z | NikoNyrh |
| 060 | Perl5.8.9 | 170509T110944Z | Tom Tann |
| 010 | Jelly | 170509T052922Z | fireflam |
| 082 | BrainFlak | 170509T133720Z | Riley |
| 015 | CJam | 170509T131958Z | Business |
| 031 | Perl 5 | 170509T114356Z | Dada |
| 108 | JavaScript | 170509T065035Z | Arjun |
| 030 | dc | 170509T102634Z | eush77 |
| 008 | 05AB1E | 170509T100421Z | Adnan |
| 065 | Mathematica | 170509T091825Z | ZaMoC |
| 089 | PHP | 170509T090754Z | Jör |
| 016 | CJam | 170509T084349Z | Luis Men |
| 010 | MATL | 170509T083711Z | Luis Men |
| 057 | Python 2 | 170509T082845Z | ElPedro |
| 014 | J | 170509T080842Z | Zgarb |
| 014 | Brachylog 2 | 170509T063757Z | user6213 |
| 042 | Python 3 | 170509T053107Z | Leaky Nu |
| 008 | Jelly | 170509T054649Z | Dennis |
| 032 | Octave | 170509T045530Z | rahnema1 |
| 010 | Pyth | 170509T044541Z | isaacg |
Julia 0.6, 29 bytes
~a=(!x=a[x:3:end])(3)[!2.<!1]
In Julia 1.0, a space is required to disambiguate the period, which could be either a decimal or part of a dot operator.
-2 bytes thanks to MarcMush: use return value from function definition
Go, 87 bytes
func(A[]int)(O[]int){for i:=0;i<len(A);i+=3{if A[i]>A[i+1]{O=append(O,A[i+2])}}
return}
APL (Dyalog Unicode), 38 29 25 bytes
{((0=3|⍳⍴⍵)^⍵>1⌽⍵)/2⌽⍵}
The index origin is set to 0 (⎕IO←0).
Nibbles, 7.5 bytes (15 nibbles)
.|`/3$`/<<$-/\
.|`/3$`/<<$-/\
`/3$ # split into chunks of 3
| # and filter these for positive results of
`/ # folding over
<<$ # the group without the 3rd (last) element
- # by subtraction
. # now map over the remaining groups of 3
\ # reverse each
/ # and now get the first element
janet, 60 bytes
(fn[l](map last(filter(fn[x](<(x 1)(x 0)))(partition 3 l))))
Vyxal, 8 bytes
3ẇR∩÷<Tİ
There are a ton of 8-byters but I haven't been able to find a single 7-byter.
3ẇ # Cut into chunks of length 3
R # Reverse each chunk
∩÷ # Transpose and push each row to the stack
< # For each, check if second > first
Tİ # Only keep third elements where ^ is truthy
Thunno 2, 8 bytes
3ẇ{rẸ<?£
Explanation
3ẇ{rẸ<?£ # Implicit input
3ẇ # Split into threes
{ # Loop over them:
rẸ # Reverse and dump
< # Check if less than
?£ # If true, print
Pip -xp, 14 bytes
_@2M$>H_FIa<>3
Takes the list as a command-line argument. Attempt This Online!
Explanation
a ; First command-line argument
<>3 ; Grouped into sublists of length 3
FI ; Filtered on this function:
H_ ; Prefix (all but the last item)
$> ; Folded on > (in this case, truthy iff the first item > the second)
M ; Map this function to each remaining sublist:
_@2 ; Get the item at index 2
No flags, 14 bytes
Here's a recursive solution without flags:
Ib<aPcIgfVg@>3
Takes the numbers as separate command-line arguments. Attempt This Online!
Explanation
Ib<a ; If the second argument is less than the first:
Pc ; Print the third argument
Ig ; If the arglist is truthy (not empty):
fV ; Call the current function again with arglist...
g@>3 ; ... current arglist without the first three elements
When g is empty, all of a, b, and c are set to nil. Since nil is not less than nil, b<a is false and the first if statement is not executed.
R, 31 bytes
Thanks to @Giuseppe again -1 byte:
f=\(x)x[!2:0][x[!-1:1]<x[!0:2]]
Thanks to @Giuseppe again -2 bytes:
f=\(x)x[!-2:0][x[!-1:1]<x[!0:2]]
With the R 4.1 it is a new game play (34 bytes). ;)
f=\(x)x[(i<--1:1)>0][x[!i]<x[i<0]]
where \(x) is a shorthand for the function(x).
37 bytes version with scan() which I do not like, but it makes it shorter.
x=scan();x[(i<--1:1)>0][x[!i]<x[i<0]]
Version with function() which is easier to test (41 byte)
f=function(x)x[(i<--1:1)>0][x[!i]<x[i<0]]
Thanks to the @Giuseppe! Nice idea to use recycling of index.
Test:
f(c())
f(c(1,2,3,4,5,6,7,8,9))
f(c(2,1,3,5,4,6,8,7,9))
f(c(3,1,4,1,5,9,2,6,5))
f(c(100,99,123))
f(c(123,123,456))
f(c(456,123,789))
Output:
> f(c())
NULL
> f(c(1,2,3,4,5,6,7,8,9))
numeric(0)
> f(c(2,1,3,5,4,6,8,7,9))
[1] 3 6 9
> f(c(3,1,4,1,5,9,2,6,5))
[1] 4
> f(c(100,99,123))
[1] 123
> f(c(123,123,456))
numeric(0)
> f(c(456,123,789))
[1] 789
Ly, 17 bytes
0&n[spG[rlr!]pp]p
This is a pretty much a direct mapping of the rules to code... After reading all the numbers onto the stack, each iteration of the loop processes the top three numbers on the stack. If the 2nd is less than the 1st, the third is appended to the end of the stack.
Once the 0 delimiter is hit on the stack, the program exits and the default action to print everything on the stack as numeric takes care of the output.
0 - add a "0" delimiter to stop the loop
&n - read all the numbers into the stack (expects one per line)
[ pp] - loop to process three nums ("pp" pops a work var and the 1at num)
sp - save the 3rd number and pop it from the stack
G - compare the 1st and 2nd
[ !] - true if 2nd is less than 1st
rlr - reverse the stack, load 3rd char, reverse again
p - pop the "0" delimiter, leaving just the answers
GolfScript, 17 bytes
~3/{~@@>{}{;}if}%
Explanation
~ # Evaluate the input
3/ # Split the input into chunks of 3
{ }% # Map every item in the input
~@@> # Is the 1st item < second item?
{}{;}if # If false, discard the current item
Japt, 18 12 bytes
ò3 f_v >ZvÃc
Or 10 bytes if returning a nested array is permitted, e.g. [[3],[6],[9]]
ò3 f_v >Zv
Husk, 8 bytes
ṁΓȯΓ↑<C3
Explanation
This program is a bit involved, so bear with me.
ṁΓȯΓ↑<C3 Implicit input (list of integers).
C3 Split into slices of length 3.
ṁ Map over slices and concatenate results
ΓȯΓ↑< of this function, explained below.
The function ΓȯΓ↑< takes a list of length 3, x = [a,b,c].
The first Γ splits x into a and [b,c], and feeds them as arguments to the function ȯΓ↑<.
This should be equivalent to ((Γ↑)<), but due to a bug/feature of the interpreter, it's actually equivalent to (Γ(↑<)), interpreted as a composition of Γ and ↑<.
Now, a is fed to the latter function using partial application, the resulting function ↑<a is given to Γ, which deconstructs [b,c] into b and [c].
Then b is fed to ↑<a, resulting in a function that takes the first b<a elements from a list.
This function is finally applied to [c]; the result is [c] if a>b, and [] otherwise.
These lists are concatenated by ṁ to form the final result, which is printed implicitly.
Without the "feature", I would have 9 bytes:
ṁΓoΓo↑<C3
JavaScript (ES6), 46 44 42 41 39 bytes
a=>a.filter((_,y)=>y%3>1&a[y-1]<a[y-2])
- Saved 2 bytes thanks to Neil.
Try It
Input a comma separated list of numbers, without any spaces.
f=
a=>a.filter((_,y)=>y%3>1&a[y-1]<a[y-2])
i.oninput=_=>o.innerText=JSON.stringify(f(i.value.split`,`.map(eval)))
console.log(JSON.stringify(f([]))) // []
console.log(JSON.stringify(f([1,2,3,4,5,6,7,8,9]))) // []
console.log(JSON.stringify(f([2,1,3,5,4,6,8,7,9]))) // [3,6,9]
console.log(JSON.stringify(f([3,1,4,1,5,9,2,6,5]))) // [4]
console.log(JSON.stringify(f([100,99,123]))) // [123]
console.log(JSON.stringify(f([123,123,456]))) // []
console.log(JSON.stringify(f([456,123,789]))) // [789]
<input id=i><pre id=o>
Explanation
a=> :Anonymous function taking the input array as an argument via parameter a
a.filter((_,y)=> :Filter the array by executing a callback function on each element,
with the index of the current element passed through parameter y.
If the function returns 0 for any element, remove it from the array.
y%3>1 :Check if the modulo of the current index is greater than 1.
(JS uses 0 indexing, therefore the index of the 3rd element is 2; 2%3=2)
& :Bitwise AND.
a[y-1]<a[y-2] :Check if the element at index y-1 in array a
is less than the element at index y-2
) :End filtering method
Scala, 74 66 bytes
Edit: Lost 8 bytes thanks to @AlecZorab
The suggestion was to use collect() instead of the equivalent filter() followed by map() (which my for comprehension is equivalent to) and a pattern match, kind of like:
(_:Seq[Int]).grouped(3).collect{case(Seq(a,b,c))if(a>b)=>c}.toList
Another suggestion was to drop the parameter name as it was only used once.
The character/byte count can be dropped to 59 bytes if an iterator is an acceptable output. Usage is similar to the old version.
Old version:
(s:Seq[Int])=>(for(l<-s.grouped(3)if l.size>2&l(0)>l(1))yield l(2)).toList
Straightforward. The toList at the end is to consume the iterator produced - toSeq produces a Stream in my tests, which shows only the first element. If the iterator itself is legal as output, this version comes in at 64 bytes:
(s:Seq[Int])=>for(l<-s.grouped(3)if l.size>2&l(0)>l(1))yield l(2)
Scala allows Unicode operators, so I could lower the character count to 62 at the cost of increasing the byte count to 66:
(s:Seq[Int])⇒for(l←s.grouped(3)if l.size>2&l(0)>l(1))yield l(2)
Lambda, the parameter type is required in the REPL. Enter into the REPL and call the res0 or whatever function object it shows with the Seq[Int] to test with. For ease of testing, you can consider the following function which converts a test case String into a proper Seq[Int]:
def testCaseAsSeq(input: String): Seq[Int] =
input.drop(1).dropRight(1)
.split(",")
.filter(! _.isEmpty)
.map(_.toInt).toSeq
Prettified version with some obfuscations removed to make it more standard Scala:
(sequence: Seq[Int]): List[Int] =>
(for(group <- s.grouped(3)
if group.size == 3 && group(0) > group(1))
yield group.last)
.toList
Ruby, 37 35 bytes
->a{a.map{x,y,z,*a=a;z&&x>y&&p(z)}}
How it works:
->a{
a.map{ -> Loop [a.size] times
x,y,z,*a=a; -> get and remove 3 elements from a
z&&x>y&&p(z) -> print z if not null and x>y
}}
Awk, 27 bytes
{a[b=NR%3]=$0}!b&&a[2]<a[1]
Mathematica, 37 bytes
Assuming this does satisfy the spec, ngenisis gets credit for this approach leading to a 1-byte saving!
BlockMap[If[#>#2,Print@#3]&@@#&,#,3]&
Pure function. BlockMap[...,#,3]& splits the input list into sublists of length 3 and then operates on each sublist with the function If[#>#2,Print@#3]&@@#&. The result is that each qualifying last number is printed. The function also returns a value (namely a list of Nulls a third as long as the input list), which seems to be allowed behavior.
Mathematica, 42 38 bytes
Thanks to Martin Ender for saving 4 bytes!
Cases[#~Partition~3,{a__,b_}/;a>0:>b]&
Pure function. #~Partition~3 does what you think. Cases[X,P:>Q] selects all the elements of X matching the pattern P, and returns the result of the transformation rule :>Q applied to each instance. Here, the pattern being matched is {a__,b_}/;a>0: b_ will match the last element of the list and a__ all the other elements (in this case, the first two); call them y and z for now. The sneaky a>0 then expands to y>z>0, which is the test we want to apply (valid because the spec says everything will be a positive integer). And the transformation rule is :>b, which simply replaces each matching ordered triple with its last element.
Original submission:
Last/@Select[#~Partition~3,#.{1,-1,0}>0&]&
Pure function; pretty much a straightforward implementation, other than #.{1,-1,0} which calculates the difference between the first and second elements of each 3-element sublist.
Mathematica, 42 39 bytes
Edit: Saved 3 bytes thanks to Greg Martin
BlockMap[Apply[If[#>#2,#3,Nothing]&],#,3]&
BlockMap[If[#>#2,#3,Nothing]&@@#&,#,3]&
Not shorter than Greg Martin's answer, but I couldn't resist the opportunity to finally use BlockMap. Partitions the input list # into sublists of size 3 and Applys the functions If[#>#2,#3,Nothing]& to each sublist.
Questionable solution, 38 bytes
BlockMap[If[#>#2,Print@#3]&@@#&,#,3]&
Same as above, except it prints the desired elements and returns {Null,...Null}.
><>, 19 + 3 for -v = 22 bytes
rl?!;(?\~r
naaao~ \
Alice, 12 11 bytes
Thanks to Leo for saving 1 byte.
I.h%I-rI~$O
Uses the code points of a string as the input list and outputs the character corresponding to the outputs that should be kept.
Explanation
I Read x. Pushes -1 on EOF.
.h% Compute x%(x+1). This terminates the program due to division by zero at EOF,
but does nothing for non-negative x.
I Read y.
- Compute x-y. We only want to output z is this is positive.
r Range. Pushes 0 1 ... n for positive n, and -n ... 1 0 for negative n
(and simply 0 for n = 0). So this results in a positive number on top
of the stack iff x-y is positive.
I Read z.
~ Swap it with x-y > 0.
$O Output z iff x-y > 0.
Then the IP wraps to the beginning of the program to process the next triplet.
C#, 126 Bytes
using System.Linq;i=>Enumerable.Range(0,i.Length/3).Select(u=>3*u).Where(u=>i[u]>i[u+1]).Select(u=>i[u+2]);
If you want a whole program with the method it'd be 175 Bytes:
using System.Linq;namespace S{class P{static System.Collections.IEnumerable X(int[]i)=>Enumerable.Range(0,i.Length/3).Select(u=>3*u).Where(u=>i[u]>i[u+1]).Select(u=>i[u+2]);}}
Saved 7 Bytes with the help of TheLethalCoder
R, 35 bytes
(x=matrix(scan(),3))[3,x[2,]<x[1,]]
Retina, 42 36 bytes
\d+
$*
M!`1+ 1+ 1+
A`^(1+) \1
%r`1\G
Try it online! Takes input as a space-separated list of numbers and outputs a newline-separated list of numbers. Edit: Saved 6 bytes thanks to @MartinEnder. Explanation:
\d+ Match input numbers
$* Convert to unary
M!`1+ 1+ 1+ Capture groups of three numbers
A`^(1+) \1 Filter out if the first is less than or equal to the second
%r`1\G Convert the third to decimal
Java 7, 86 85 bytes
void c(int[]a){for(int i=-1;++i<a.length;)if(a[i++]>a[i++])System.out.println(a[i]);}
-1 byte thanks to @PunPun1000
Explanation:
void c(int[]a){ // Method with integer-array parameter and no return
for(int i=-1;++i<a.length;) // Loop over the array in steps of three at a time
if(a[i++]>a[i++]) // If the value of the current index is larger than the next:
System.out.println(a[i]); // Print the value on the third index
// End of loop (implicit / single-line body)
} // End of method
Röda, 15 bytes
{[_3]if[_2<_1]}
Röda is nearly as short as the golfing languages...
This takes three values from the stream, and pushes the third (_3) back, if the second (_2) is less than the first (_1).
The underscores are syntax sugar for for loops, so the program could be written as {{[a]if[b<c]}for a,b,c} or even {[a]for a,b,c if[b<c]}.
No TIO link, because it doesn't work on TIO for some reason (although works with the latest version of Röda that predates the challenge).
Haskell, 30 29 bytes
x(a:b:c:l)=[c|b<a]++x l
x d=d
My first attempt at golfing Haskell, so I may have missed an optimization or two
-1 byte thanks to @JulianWolf
Clojure, 43 bytes
#(for[[a b c](partition 3 %):when(< b a)]c)
Boring :/
Perl5.8.9, 73 60 bytes
while(@F){@b=splice@F,0,3;$b[1]<$b[0]&&print$b[2]}print"-"
(58+2 for the 'n' flag to read the whole file and a to autosplit). Assumes the input is lines of space separated numbers
Reduction thanks to Dada. Including the print at the end for visibility, that'd save 8 bytes if not.
Jelly, 10 bytes
s3µṪWx>/µ€
or
-3 bytes thanks to @LeakyNun
Explanation
s3µṪWx>/µ€
s3 - split into groups of three
µ µ€ - on each group, do:
ṪW - return the third element as the only element of a list
x - repeat each element in that list the number of times
>/ - corresponding to 1 if the second element of the group is greater than the first; 0 otherwise.
Brain-Flak, 82 bytes
{([({}[{}()]<(())>)](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}{{}((<({}<>)<>>))}{}{}}<>
# Until the stack is empty (input is guaranteed to not contain 0)
{
# Push 1 for greater than or equal to 0
([({}[{}()]<(())>)](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}
# ^------^ This part is Top - (Second + 1)
# If the second number was less than the first...
{{}
# Get ready to push 2 zeros
((<
# Move the next number to the other stack
({}<>)<>
# Push those 2 zeros
>))}
# Pop 2 values.
# This is either 2 zeros, or a 0 and a "last number" that shouldn't be printed
{}{}
# End loop
}
# Switch to the stack where we stored the numbers to be printed
<>
CJam, 15 bytes
{3/{)\:>{;}|}%}
Anonymous block which expects argument on the stack, and leaves the result on the stack.
Try it online! (Runs all test cases)
Explanation
3/ e# Split the list into length-3 chunks.
{ e# For each chunk:
) e# Remove the last element.
\:> e# Reduce the first 2 elements by greater than.
{;}| e# If the first is not larger than the second, delete the third.
}% e# (end for)
Perl 5, 31 bytes
30 bytes of code + -p flag.
s/\d+ (\d+) (\d+)/$2if$1<$&/ge
Replaces each group of 3 numbers (\d+ (\d+) (\d+)) by the third ($2) if the second ($1) is less than the first ($&), and nothing otherwise.
JavaScript, 108 107 108 bytes
This is a valid JS anonymous (lambda) function. Add x= at the beginning and invoke like x([5,4,9,10,5,13]). Outputs as function return.
a=>(y=[],a.map((c,i)=>(i+1)%3?0:y.push(a.slice(i-2,i+1))),y.map(v=>v[1]<v[0]?v[2]:null).filter(c=>c|c==0))
The snippet takes in the input as a list of comma separated integers.
x=a=>(y=[],a.map((c,i)=>(i+1)%3?0:y.push(a.slice(i-2,i+1))),y.map(v=>v[1]<v[0]?v[2]:null).filter(c=>c|c==0))
martin.oninput = e => { dennis.innerHTML = x(martin.value.split`,`.map(c=>parseInt(c,10))) }
<input type=text id=martin><pre id=dennis>
Mathematica 65 bytes
{K={};Cases[Partition[#,3],{a_,b_,c_}->If[b<a,AppendTo[K,c]]];K}&
PHP, 89 Bytes
<?print_r(array_filter($_GET,function($v,$k){return $k%3>1&&$_GET[$k-1]<$_GET[$k-2];},1));
CJam, 16 bytes
q~3/{~@@>S{;}?}%
The output is shown as numbers separated by spaces.
Explanation
q~ e# Read input list
3/ e# List of sublists of length 3
{ }% e# Apply this to each sublist
~ e# Push sublist contents: 3 numbers
@@ e# Rotate twice. This moves first two numbers to top
> e# Greater than?
S{;}? e# If so: push space (used as separator). Else: pop the third number
e# Implicitly display
MATL, 10 bytes
IeI&Y)d0<)
The result is displayed as numbers separated by spaces.
Or verify all test cases. This displays a string representation of the output, so that an empty array is actually seen as []. Note that in MATL a number is the same as a singleton array, so [4] is shown as 4.
Explanation
Ie % Implicit input. Reshape as a 3-row matrix (column-major order)
I&Y) % Split into the third row and a submatrix with the other two rows
d % Consecutive difference along each column of the submatrix
0< % True for negative values
) % Use as logical index into the original third row. Implicitly display
J, 14 bytes
_3&(>`[/\#]/\)
This evaluates to a monadic verb. Try it online!
Explanation
_3&(>`[/\#]/\) Input is y.
_3&( \ ) For each non-overlapping 3-element chunk of y,
>`[/ check if first element is greater than second.
Call the resulting array x.
_3&( \) For each non-overlapping 3-element chunk of y,
]/ take the last element.
# Keep those where the corresponding element of x is 1.
Brachylog (2), 14 bytes
~c{Ṫ}ᵐ{k>₁&t}ˢ
Brachylog rather struggles with this sort of problem. Note that this program has horrible computational complexity, as it brute-forces splitting the input into groups of 3 (having no "split into groups" builtin); it runs quickly with four groups but very slowly with five.
Explanation
~c{Ṫ}ᵐ{k>₁&t}ˢ
~c Split into groups
{ }ᵐ such that each group
Ṫ has three elements
{ }ˢ then on each element, skipping that element on error:
k with the list minus its last element
>₁ assert that it's strictly decreasing
& and with the original list
t keep only its last element
Jelly, 9 8 bytes
>Ḋm3T×3ị
How it works
>Ḋm3T×3ị Main link. Argument: A (array)
Ḋ Dequeue; yield A without its first element.
> Compare the elements of A with the elements of the result.
m3 Select each third element, starting with the first.
T Truth; get all indices of truthy elements.
×3 Multiply those indices by 3.
ị Unindex; retrieve the elements at the redulting indices.
Octave, 32 bytes
@(L)L(x=3:3:end)(diff(L)(x-2)<0)
or
L3 = L(3:3:end) %extract last elements of groups
d= diff(L) % first difference of the list
y=d(1:3:end) %extract first elements of each subgroup of the difference
idx = y<0 %check for negative numbers
result = L3(idx)
Pyth, 10 bytes
eMf>FPTcQ3
eMf>FPTcQ3
cQ3 Chop the input into groups of size 3
f Filter on
PT All but the last element
>F Apply the greater than function
eM Map to the last element