Подписывайтесь на наш Telegram-канал! Ежедневно интересно!

Подписывайтесь на наш Telegram-канал!

Помочь нашему сайту финансово на сервисе сбора донатов!

Помочь нашему сайту финансово!
 
HostLife - лучший платный хостинг

Toy Robot - The Elixir Version

  • Заявить о правах (Abuse)
Автор: Limpopo5 от 2021-12-21, 06:07:05
Toy Robot - The Elixir VersionНазвание: Toy Robot - The Elixir Version
Автор: Ryan Bigg
Издательство: Leanpub
Год: 2021-01-18
Страниц: 224
Язык: английский
Формат: pdf (true), mobi, epub
Размер: 10.2 MB

The Toy Robot is a common interview exercise for new programmers. This short book will take you through how to implement it in Elixir in a BDD-style, with some great explanations and imagery along the way.

The Toy Robot exercise was originally developed by Jon Eaves. He explains why he did it in this blog post. If you're a new Elixir developer who's gone through some basic Elixir tutorials and you're looking for the next thing to build your skills, this book is a great start. It covers the Toy Robot exercise from start to finish, testing with Elixir features such as ExUnit and Doctests along the way. The Toy Robot exercise is commonly used in interviews as the ways to solve it in any language are not as simple as they first may seem. This book covers one implementation of this exercise in Elixir. It is not intended to be the most perfect implementation of the Toy Robot exercise possible, but instead is my personal take on it.

In this book, I’m going to go through how I would implement the Toy Robot exercise myself in Elixir, just for demonstration purposes. I’ll be building it up piece-by-piece with the overall aim to be to help anyone reading how to think through and implement this problem. This book is not intended to be the ultimate 100% perfect and make people weep with joy at the elegance of the solution type of deal. It is my approach to the Toy Robot problem and I’m sharing it with you in the hope you may gain something from it. There may, nay, WILL be better ways to write what I have written here. It is up to you find out what they are. (And then to tell me so that I too may learn!)

This version focusses on Elixir and its testing framework, ExUnit. In this book, I’ll be assuming that you have a base-level of Elixir knowledge. If you’ve gone through my other Elixir book, Joy of Elixir, you’ll have the right amount of knowledge. You’ll know about lists, maps, functions, and modules. All things that we’ll use a lot of in this book. Consider this Toy Robot book a spiritual sequel to Joy of Elixir. If you haven’t gone through that book but have learned Elixir elsewhere, then I would expect you to have done enough reading about Elixir to know your modules from your functions, as well as lists and maps too. I am also going to assume a base-level understanding of test-driven design.

In this book, I demonstrate best practices for developing a small Mix application that can solve the Toy Robot exercise. Along the way, you'll learn about:

How to break a complex problem down into small, approachable chunks
When to use Doctests or regular ExUnit tests
Tradeoffs between different ways of pattern matching
How to work with Elixir processes using GenServer + DynamicSupervisor

The Toy What Now?
The Toy Robot! It's a very common interview exercise given to new programmers. Here's the variant of the problem's description that we use in the book:

The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units. There are no other obstructions on the table surface. The robot is free to roam around the surface of the table. Any movement that would result in the robot falling from the table is prevented, however further valid movement commands are still allowed.

The application reads a file using a name passed in the command line, the following commands are valid:

PLACE X,Y,F
MOVE
LEFT
RIGHT
REPORT

Here's some rules for these commands:

PLACE will put the toy robot on the table in position X,Y and facing NORTH, SOUTH, EAST or WEST.
The origin (0,0) is the SOUTH WEST most corner.
All commands are ignored until a valid PLACE is made.
MOVE will move the toy robot one unit forward in the direction it is currently facing.
LEFT and RIGHT rotates the robot 90 degrees in the specified direction without changing the position of the robot.
REPORT announces the X,Y and F of the robot.

The file is assumed to have ASCII encoding. It is assumed that the PLACE command has only one space, that is PLACE 1, 2, NORTH is an invalid command. All commands must be in upcase, all lower and mixed case commands will be ignored.

Скачать Toy Robot - The Elixir Version






Выгодные предложения от нашего партнёра ИГ "ЭКСМО-АРТ":

Акция С заботой о здоровье и безопасности




 


BooksKeeper - электронная библиотека, ежедневно пополняемая нашими авторами.
Все материалы, представленные на нашем сайте, Вы сможете скачать по ссылкам различных бесплатных файлообменников совершенно бесплатно!
Инструкции, поясняющие, как надо качать бесплатно с файлообменников смотреть тут
Регистрация на нашем сайте позволит Вам добавлять свои книги, а также комментировать опубликованные книги, общаться с нашими авторами.
Для этого мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем.

Информация
Посетители, находящиеся в группе Гости, не могут оставлять комментарии к данной публикации.

HostLife - лучший платный хостинг
HostLife - лучший платный хостинг!
Отличный хостинг по цене от 1.87$/месяц! Рекомендация от сайта Bookskeeper!


Бесплатная электронная библиотека. Скачать книги бесплатно!

Наша электронная библиотека Bookskeeper (для РФ работает через VPN) - это интернет-витрина, где любой посетитель может публиковать электронные варианты книг, журналов, газет, комиксов, в общем, любой литературы со ссылками для медленного, но бесплатного скачивания с файлообменников. В нашем книжном хранилище Вы всегда найдете литературу на любой вкус человека любого возраста - от детских комиксов и расскрасок до серьезной научной литературы.
 
 
Поддержите наш сайт!
Идет сбор донатов на хостинг
для работы нашего сайта.
Сканируйте QR-код
(или нажмите на него)
для Вашей поддержки!
Оплата картой, ЮMoney


Донаты для помощи нашему сайту!

ОГРОМНОЕ СПАСИБО
всем за Ваши донаты!

Наши рекомендации



Book24.ru - книжный интернет магазин



Turbobit - Получите турбо-доступ и скачивайте безлимитно и без рекламы!


HostLife - лучший платный хостинг