Giter VIP home page Giter VIP logo

triangles's Introduction

triangles

Two simple solutions to determining the type of the triangle, based on the lengths of its edges.

Erlang

Erlang solutions saves as a baseline.

  • triangle module allows for creation of new triangle structures and can be extended with more API for manipulating triangles. This is standard for creating data structures and modules operating on them in Erlang
  • the triangle type can be determined using triangle module API as an atom
  • eUnit unit tests for validity
  • simple_input is made for simplicity sake with a try/catch block - in normal operations a process that attempts to create an invalid triangle should crash with an exception in order to fail early and identify the source of invalid data easily

Scala

Scala solutions serves as a learning opportunity

  • Simple solution given the simple problem specification
  • Triangle class inherits from Polygon allowing for other shapes to be added later
  • The edge type of the triangle is calculated upon object creation for efficiency
  • Triangle is a case class allowing for pattern matching
  • EdgeType is a sealed class as no other edge types exist in geometry
  • Experimenting with ScalaCheck to do Erlang-like performance-based testing

Alternatively, an older commit contains implementation where each triangle type is a different class that inherits from Triangle allowing for defining of different behavior for each triangle type. This could be further enhanced with EdgeType becoming a trait and its sub-traits being mixed with different triangle types.

triangles's People

Contributors

haljin avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.