Created
November 4, 2015 02:16
-
-
Save MonkeyIsNull/13aec9eac86489db15f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Rdd do | |
def top() do | |
threads = Reddhl.pull("elixir") | |
{ Reddhl.url(threads, 1), Reddhl.title(threads, 1) } | |
end | |
def top_five do | |
threads = Reddhl.pull("elixir") | |
Enum.map(0..4, fn(x) -> { Reddhl.url(threads, x), Reddhl.title(threads, x) } end) | |
end | |
def fetch(num) do | |
threads = Reddhl.pull("elixir") | |
{ Reddhl.url(threads, num), Reddhl.title(threads, num) } | |
end | |
def looper([]) do | |
end | |
def looper([hd|tail]) do | |
IO.inspect Task.await(hd) | |
looper(tail) | |
end | |
def task_five do | |
Enum.map(0..4, fn(x) -> Task.async(Rdd, :fetch, [x]) end) | |
end | |
# This is the PUB API | |
def fetch_top_five do | |
looper task_five | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment