Some exercises to get you familiar with programming in Elm.
runIntroduction : Exercises -> Platform.Program () Model Message
To complete this lab, import this library in your own file,
create an appropriate Exercises
value, and use your Exercises
value
with runIntroduction
.
module Main exposing (main)
import ElmTeachingTools.Labs.Introduction exposing (..)
myExercises : Exercises
myExercises =
{ -- your code here
}
main =
runIntroduction myExercises
{ ex0_sayHello : String -> String
, ex1_countVowels : String -> Basics.Int
, ex2_toCamelCase : String -> String
, ex3_diffList : List Basics.Int -> Maybe (List Basics.Int)
, ex4_partialSums : List Basics.Int -> List Basics.Int
, ex5_simpleCalc : String -> String
}
This lab consists of six exercises to help you get started learning the basics of Elm and how to use it to write interactive web programs.
ex0_sayHello : String -> String
Give someone a nice, name-appropriate greeting.
If their name ends with "y", give them a friendly "Hey,
ex1_countVowels : String -> Int
Count the number of vowels in the input.
For the purposes of this exercise, the letters "a", "e", "i", "o",
and "u" are considered vowels.
(Upper-case versions are also vowels!)
ex2_toCamelCase : String -> String
Convert a sentence to camelCase.
Capitalize the first letter of each word except the first,
make sure all other letters are lower case,
and remove all spaces.
ex3_diffList : List Int -> Maybe (List Int)
Given a list of positive integers,
compute the list of differences between successive terms.
Notice, this list will be one shorter than that starting list.
If the user gives only one integer, return an empty list.
If the user gives empty input, return Nothing
".
ex4_partialSums : List Int -> List Int
Given a list of positive integers,
compute the list of partial sums, starting with 0.
Notice your list will be one longer than the input list.
If the user gives empty input, return the list [0]
.
ex5_simpleCalc : String -> String
Make a calculator capable of addition and multiplication of integers.
Follow the ordinary order of operations, multiplication then addition.
A -
sign will always mean "negative" and never mean subtraction.
If the input has any characters other than digits, *
, +
, and -
,
return the string, "Sorry, bad input!".