Transformation: Take First n Items

Our next transformation is to extract the first count entries from the list. Resisting the temptation to write the function ourselves,[25] we discover the built-in Enum.take:

 def​ process({user, project, count}) ​do
  Issues.GithubIssues.fetch(user, project)
  |> decode_response
  |> convert_to_list_of_maps
  |> sort_into_ascending_order
» |> Enum.take(count)
 end

Get Programming Elixir 1.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.