Deck - double comprehension usage

Run Settings
LanguageElixir
Language Version
Run Command
defmodule Deck do def cards do ranks = [ "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" ] suits = [ "♣", "♦", "♥", "♠" ] for rank <- ranks, suit <- suits, do: {rank, suit} end def random(num) do random(Deck.cards, num) |> Enum.shuffle |> Enum.take(num) end def random(cards, num) do cards |> Enum.shuffle |> Enum.take(num) end def hands(num_players, num_cards_hand) do Deck.random(num_players * num_cards_hand) |> Enum.chunk_every(num_cards_hand) end end IO.inspect Deck.hands 3, 5
Editor Settings
Theme
Key bindings
Full width
Lines