Pastebin
API
tools
faq
paste
Login
Sign up
SHARE
TWEET
Untitled
a guest
Oct 20th, 2018
75
0
Never
Add comment
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!
text
0.17 KB
| None
|
0
0
raw
download
clone
embed
print
report
def remove_consecutive_duplicates(xs)
[xs.first] + xs.each_cons(2).select do |x,y|
x != y
end.map(&:last)
end
remove_consecutive_duplicates([1, 2, 2, 3, 1])
#=> [1,2,3,1]
Add Comment
Please,
Sign In
to add comment
Public Pastes
🤑 G2A.com Free Gift Card Guide May 2024 FIX 💰
GetText | 7 min ago | 0.38 KB
Untitled
JavaScript | 15 min ago | 0.30 KB
Triplet Solution
C++ | 39 min ago | 0.62 KB
reactor_controller
Lua | 48 min ago | 0.45 KB
🤑 G2A.com Free Gift Card Guide May 2024 FIX 🤑
GetText | 1 hour ago | 0.39 KB
Untitled
C++ | 1 hour ago | 0.47 KB
exemple
C# | 1 hour ago | 0.20 KB
DMVCFramework :: Uploading multiple files
Delphi | 1 hour ago | 1.57 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!