Browse Source

Exercise 2.1 Write a function of suffixes of type...

List a -> List (List a) that takes a list `xs` and returns a list of all the
suffixes of `xs` in decreasing order of length.
master
Aaron VonderHaar 5 years ago
commit
8fe56d5ca0
  1. 2
      .gitignore
  2. 18
      exercises/2.1 list suffixes/Main.elm
  3. 15
      exercises/2.1 list suffixes/elm-package.json

2
.gitignore

@ -0,0 +1,2 @@
elm-stuff/
index.html

18
exercises/2.1 list suffixes/Main.elm

@ -0,0 +1,18 @@
module Main exposing (..)
import Html exposing (Html)
suffixes : List a -> List (List a)
suffixes list =
case list of
[] ->
[ [] ]
next :: rest ->
list :: suffixes rest
main : Html msg
main =
Html.text <| toString <| suffixes [ 1, 2, 3, 4 ]

15
exercises/2.1 list suffixes/elm-package.json

@ -0,0 +1,15 @@
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "4.0.1 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.17.0 <= v < 0.18.0"
}
Loading…
Cancel
Save