Your friend Paula is trying to get better at solving crossword clues. She has read that some clues show that the answer is a palindrome. A palindrome is a word or sentence that reads the same backards as forwards.
She asks you write her a very simple website that will check whether a string is a palindrome (or not) so that she can check her guesses.
You decide to do this using an Elm [sandbox][browser-sandox] application.
The application will have a text box, that Paula can type her guess into, and text stating whether or not the text in the box is a palindrome. The text will update whenever the text in the text box changes.
Model and Msg types for the application, and write the init functionThe application Model needs the string to check, this field should be called content.
The application needs a Msg to indicate that the text in the Text Box has changed.
The variant for this should be called Change
The init function should return a initial Model value with an empty content field.
The update function should take a Msg and a Model parameter, and return a new Model.
The Msg will carry some text typed by the user, and the new Model should include that text.
Elm requires that the view function has to return an Html msg type, which means that you need to return a single element from the view function (and not an array of elements).
Inside this root element, there should be an input element (the Text Box), and a div with text content to state whether the text in the input is a palindrome or not.
The text should be "This is a palindrome" or "Not a palindrome".
The main function should call Browser.sandbox, passing a record parameter with the init, update and view functions.
To make the exercise work on the Exercism online editor, we use a fake Browser.sandbox with the code.
This makes no difference to the code that you write to solve this exercise.
Your friend Paula is trying to get better at solving crossword clues. She has read that some clues show that the answer is a palindrome. A palindrome is a word or sentence that reads the same backards as forwards.
She asks you write her a very simple website that will check whether a string is a palindrome (or not) so that she can check her guesses.
You decide to do this using an Elm [sandbox][browser-sandox] application.
The application will have a text box, that Paula can type her guess into, and text stating whether or not the text in the box is a palindrome. The text will update whenever the text in the text box changes.
Model and Msg types for the application, and write the init functionThe application Model needs the string to check, this field should be called content.
The application needs a Msg to indicate that the text in the Text Box has changed.
The variant for this should be called Change
The init function should return a initial Model value with an empty content field.
The update function should take a Msg and a Model parameter, and return a new Model.
The Msg will carry some text typed by the user, and the new Model should include that text.
Elm requires that the view function has to return an Html msg type, which means that you need to return a single element from the view function (and not an array of elements).
Inside this root element, there should be an input element (the Text Box), and a div with text content to state whether the text in the input is a palindrome or not.
The text should be "This is a palindrome" or "Not a palindrome".
The main function should call Browser.sandbox, passing a record parameter with the init, update and view functions.
To make the exercise work on the Exercism online editor, we use a fake Browser.sandbox with the code.
This makes no difference to the code that you write to solve this exercise.