Giter Club home page Giter Club logo

dataico's Introduction

Engineering Challenge

Getting started

This clojure challenge is made up of 3 questions that reflect the learning you accumulated for the past week. Complete the following instructions:

  1. Create a Gitlab repo to show the challenge code. When complete, send us the link to your challenge results.

  2. Duration: About 4 hours

  3. Install Cursive Plugin to Intellij and setup a clojure deps project. https://cursive-ide.com/userguide/deps.html

  4. Enjoy!

Problems

Problem 1 Thread-last Operator ->>

Given the invoice defined in invoice.edn in this repo, use the thread-last ->> operator to find all invoice items that satisfy the given conditions. Please write a function that receives an invoice as an argument and returns all items that satisfy the conditions described below.

Requirements

  • Load invoice to play around with the function like this:
(def invoice (clojure.edn/read-string (slurp "invoice.edn")))

Definitions

  • An invoice item is a clojure map { โ€ฆ } which has an :invoice-item/id field. EG.
{:invoice-item/id     "ii2"  
  :invoice-item/sku "SKU 2"}
  • An invoice has two fields :invoice/id (its identifier) and :invoice/items a vector of invoice items

Invoice Item Conditions

  • At least have one item that has :iva 19%
  • At least one item has retention :ret_fuente 1%
  • Every item must satisfy EXACTLY one of the above two conditions. This means that an item cannot have BOTH :iva 19% and retention :ret_fuente 1%.

Problem 2: Core Generating Functions

Given the invoice defined in invoice.json found in this repo, generate an invoice that passes the spec ::invoice defined in invoice-spec.clj. Write a function that as an argument receives a file name (a JSON file name in this case) and returns a clojure map such that

(s/valid? ::invoice invoice) => true 

where invoice represents an invoice constructed from the JSON.

Problem 3: Test Driven Development

Given the function subtotal defined in invoice-item.clj in this repo, write at least five tests using clojure core deftest that demonstrates its correctness. This subtotal function calculates the subtotal of an invoice-item taking a discount-rate into account. Make sure the tests cover as many edge cases as you can!

dataico's People

Contributors

marcell1993 avatar

Watchers

Marcell Calero 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.