Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicholas Crothers Submission #5

Closed
wants to merge 1 commit into from
Closed

Conversation

ncrothers
Copy link

Name: Nicholas Crothers
ID: 47330742

Comment on lines +56 to +61
range_to_enumerable(collection)
|> splitmap(process_count)
|> spawnchunks(function)
|> receivechunks
|> flatten_result
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES!

Thank you for structuring it like this...

Comment on lines +63 to +65
def range_to_enumerable(range) do
Enum.map(range, fn x -> x end)
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range is already enumerable. In fact, this function makes that assumption, as map wouldn't work otherwise...


def spawnchunks(chunks, function) do
me = self()
Enum.map(chunks, fn chunk -> spawn(fn -> process(chunk, function, me) end) end)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good name for the variable...

@pragdave pragdave closed this Oct 20, 2019
end

def splitmap(enumerable, process_count) do
Enum.chunk_every(enumerable, div(length(enumerable), process_count))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The div here returns the wrong value (try it with 10 and 4).

-2

# « your code goes here»
# You can give an agent a name by adding the
# `name: @global_name` option to start_link
{:ok, pid} = Agent.start_link(fn -> initial_value end, name: @global_name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line generates a warning because pid is unused.

-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants