This file contains hidden or 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
// Find the top occurring elements from a vector. | |
// This is how to special a type parameter that implements multiple traits. | |
fn top_ten<T: Debug + Hash + Eq>(values: &Vec<T>) -> Vec<&T> { | |
let mut map = HashMap::new(); | |
for value in values { | |
let counter = map.entry(value).or_insert(0); | |
*counter += 1; | |
} | |
let mut map_vec: Vec<_> = map.into_iter().collect(); |
This file contains hidden or 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
I, [2019-03-21T19:30:13.389241 #18433] INFO -- : To Unison: RECURSIVE treehouse/.git/objects/pack/ | |
I, [2019-03-21T19:30:13.389300 #18433] INFO -- : To Unison: DONE | |
I, [2019-03-21T19:30:14.471515 #18433] INFO -- : From Unison: WAIT 49b3cf7d81b5d728313acd2e17440e17 | |
I, [2019-03-21T19:30:14.471642 #18433] INFO -- : To Unison: CHANGES 49b3cf7d81b5d728313acd2e17440e17 | |
I, [2019-03-21T19:30:14.552176 #18433] INFO -- : From Unison: CHANGES 49b3cf7d81b5d728313acd2e17440e17 | |
I, [2019-03-21T19:30:14.552605 #18433] INFO -- : To Unison: RECURSIVE treehouse/.git/objects/pack/ | |
I, [2019-03-21T19:30:14.552681 #18433] INFO -- : To Unison: DONE | |
I, [2019-03-21T19:30:15.636954 #18433] INFO -- : From Unison: WAIT 49b3cf7d81b5d728313acd2e17440e17 |
This file contains hidden or 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 Parallel do | |
# Allows mapping over a collection using N parallel processes | |
def pmap(collection, function) do | |
# Get this process's PID | |
me = self | |
collection | |
|> | |
Enum.map(fn (elem) -> | |
# For each element in the collection, spawn a process and | |
# tell it to: |