How to associate Integers or Float values with Boleano in ELM via HTML document?

Asked

Viewed 39 times

0

all right ? I came across a simple problem. Write an algorithm that gets a number and tells you if it is odd. The answer has to be in boleanos. If the number is odd True, if it is even False ! So far so good, in the terminal of Elm (which I have installed, but in case you have not already left this terminal online: http://elmrepl.cuberoot.in/) I was able to reproduce the function as follows: impar number = if (modBy 2 number) == 0 then False Else True (modBy he gives the rest is like % in some languages) Now comes the question ! I want to know how to make this same function be presented only in HTML code : https://ellie-app.com/new But Elm does not recognize the connection between the number Int and Bool when printing the function and ends up giving error. inserir a descrição da imagem aqui

1 answer

1


I created an auxiliary function toString(), worked in the https://ellie-app.com/new.

module Main exposing (main)

import Browser
import Html

toString : Bool -> String
toString bool = if bool then "True" else "False"

impar number = if (modBy 2 number) == 0 then False else True

main = Html.text (toString (impar 5))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.