pragdave / e4p-code Goto Github PK
View Code? Open in Web Editor NEWCode for the course "Elixir for Programmers"
Code for the course "Elixir for Programmers"
Hi,
at the end of the chapter (checkpoint 050-start-hangman-complete
) you have suggested moving make_move/2
directly under public API module Hangman
. Following the same logic, I would suggest that tally/1
should be also there. So the code would read
defmodule Hangman do
alias Hangman.Game
defdelegate new_game(), to: Game
def make_move(game, guess) do
game = Game.make_move(game, guess)
{ game, tally(game)}
end
def tally(game) do
%{
game_state: game.game_state,
turns_left: game.turns_left,
letters: game.letters |> reveal_guessed(game.used),
}
end
############################################################################
defp reveal_guessed(letters, used) do
letters |> Enum.map(fn letter -> reveal_letter(letter, MapSet.member?(used, letter)) end)
end
defp reveal_letter(letter, _in_word = true), do: letter
defp reveal_letter(_letter, _not_in_word), do: "_"
end
I've put the reveal_guessed
there as well as it seems as a transform function which is used to create a public API (sort of view functionality).
Honestly, I am not really sure if I like it :)
I have a situation where my phoenix layer connects to a postgres ecto layer before connecting to the postgres database. Should the postgres ecto layer supervisor strategy be a simple_one_for_one? Why or why not?
It Probably runs the error
:simple_one_for_one strategy is deprecated, please use DynamicSupervisor instead
Please update the course to actual versions.
Hi Dave, first off thanks for the awesome course.
Just wondering: what happened to the code?
Plenty of links in the course still lead to this repo.
I understand why you used an Agent to handle state in the Dictionary application.
What I don't understand is why you chose to use Genserver to manage state in the Hangman application. Why didn't you use Agents if they can also get the job done?
According to the docs it says this code is deprecated, but I'm still wrapping my head around the new actual code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.