Skip to content

Instantly share code, notes, and snippets.

@jouderianjr
Last active November 13, 2019 13:15
Show Gist options
  • Save jouderianjr/f3b2d9795f32a5abc1c1d3197da76b2a to your computer and use it in GitHub Desktop.
Save jouderianjr/f3b2d9795f32a5abc1c1d3197da76b2a to your computer and use it in GitHub Desktop.

You can use Ellie to "test" the code, changing only the result function and adding your extra code

Extra documentation to use this as reference:

Data Modeling exercises

1 - Represent a package containing:

  • barcode
  • status ( can only be: Delivered, Failed, On Course)
  • deliveryTime if the package was delivered (you can use String for this field)
  • failedTime if the delivery fails (you can use String for this field)

2 - Create an address type that has 2 different shapes, it can be a coordinates address or a textual address:

1 - Coordinate address, with longitude and latitude

2 - Postal address, with address line, postal code, city and country

List.map exercises

1 - Create a function that receives a list of integers and returns a new list adding 1 in each item

  • E.g. [1,2,3] -> [2,3,4]

2 - Given a list of strings, append "Hello " to each string

  • E.g. ["jouderian", "miguel", "suraj"] -> ["Hello jouderian", "Hello miguel", "Hello suraj"]

3 - Given a package(barcode and status), returns the list of barcodes

  type alias Package =
    { barcode : String, status : String }
  
  packages : List Package
  packages =
    [ { barcode = "111111", status = "Delivered" }
    , { barcode = "2222222", status = "OnCourse" }
    , { barcode = "33333", status = "Delivered" }
    , { barcode = "44444", status = "FailedDelivery" }

Extra List exercises

This exercises are using different functions that we haven't discussed yet, but you can check the documentation here and try to do it

List docs

  • Given a list of numbers, return all the numbers higher than 10
  • Given a list of packages, return all the packages that are "Delivered"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment