7 kyu

Last

976 of 8,882xcthulhu

Description:

Find the last element of the given argument(s). If a single argument is passed and is a list/array or a string, return its last element. It is guaranteed that there will be at least one argument and that single-argument arrays/lists/strings will not be empty.

Examples

last [1, 2, 3, 4]     -- =>  4
last ['x', 'y', 'z']  -- => 'z'
(last [1, 2, 3, 4]) ; => 4
(last "xyz")        ; => \z
last(Arrays.asList(1, 2, 3, 4)); // =>  4
last("xyz");                     // => "z"
last(1, 2, 3, 4);                // =>  4
last(new int[]{1, 2, 3, 4});     // =>  4
last(&[1, 2, 3, 4])     // =>  4
last(&['x', 'y', 'z'])  // => 'z'

(courtesy of haskell.org)

Lists
Fundamentals

Stats:

CreatedSep 14, 2014
PublishedSep 14, 2014
Warriors Trained15858
Total Skips821
Total Code Submissions82212
Total Times Completed8882
Haskell Completions976
Clojure Completions670
JavaScript Completions3743
Ruby Completions709
CoffeeScript Completions64
Python Completions1940
Rust Completions644
Java Completions892
Total Stars183
% of votes with a positive feedback rating77% of 1075
Total "Very Satisfied" Votes714
Total "Somewhat Satisfied" Votes223
Total "Not Satisfied" Votes138
Ad
Contributors
  • xcthulhu Avatar
  • jhoffner Avatar
  • Abbe Avatar
  • bekh6ex Avatar
  • brianweiser Avatar
  • ZozoFouchtra Avatar
  • GiacomoSorbi Avatar
  • shadowmanos Avatar
  • anter69 Avatar
  • Voile Avatar
  • Madjosz Avatar
  • trashy_incel Avatar
  • KayleighWasTaken Avatar
  • saudiGuy Avatar
Ad