Questions tagged as 'haskell'

0
answers

Binary to decimal conversion

I did an algorithm that converts from Binary to Decimal, now I need to develop one that does the opposite. I'll leave the code I made below, but this one is in error. Thank you. converte' :: [Int] -> Int converte' [] = 0 converte' (x:xs) =...
asked by 07.11.2018 / 17:29
1
answer

How to split a string with two conditions

Basically, from the string "222 2333 33" , I wanted to split into several strings when I find an empty space or a different number next to it. For example, in the above string I wanted it to be ["222","2","333","33"] . The code...
asked by 24.10.2018 / 17:02
0
answers

How does fashion in Haskell

How to find the fashion of a list of integers? I was trying and the most I got was this: moda :: [Int]->[Int] moda [a] = [] moda [] = [] moda (a:b:x) |a /= b && qtd a x > qtd b x = a : moda (b:x) |a /= b && qtd a...
asked by 22.10.2018 / 13:57
0
answers

How to handle date / time difference in haskell

I'm having trouble calculating the difference between two UTCTime instances in haskell. I need to calculate the days difference, plus the difference in days, hours and minutes. I'm getting the start time with the code: now <- getCurrentT...
asked by 02.10.2018 / 00:46
0
answers

How to implement yesod paging?

I have a problem. I need this code below to return a specific amount of lines (LimitTo), from a specific number of results (OffsetBy). The code of the application I'm doing for this purpose is this: getBuscR :: Int -> Handler Value getBuscR...
asked by 05.06.2018 / 02:03
0
answers

Fold in a binary tree in haskell

Hello, I'm trying to define the foldTree function that takes a function and a binary polymorphic tree as parameters and returns the resultant value of accumulating the application of that function by all nodes of the tree. Then add all the nodes...
asked by 14.05.2018 / 19:07
1
answer

Doubt, haskell error

I want to sum the values of a list of lists in haskell using the map function, but of the error. Error type gastoEmpresa :: [[Float]] -> Float gastoEmpresa xss = map(map sum xss)     
asked by 01.04.2018 / 15:31
0
answers

Doubts about normalization of polynomials

Define the function normalizes that given a polynomial, it returns the corresponding polynomial, after being normalized. Example: normaliza [(1,2),(3,4),(3,2)] [(4,1),(3,4)] type Polinomio = [Monomio] type Monomio = (Float,Int) normaliz...
asked by 17.12.2017 / 11:46
1
answer

Leaf Trees - Height

It is usual to define trees where the information is only in leaf trees: data LTree a = Tip a | Fork (LTree a) (LTree a) Define the following function on this type: ltHeight :: LTree a -> Int that calculates the height...
asked by 29.11.2017 / 20:05
1
answer

How to use JQuery in Yesod Haskell

I'm just trying to display a 'div' with the login fields {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE Ty...
asked by 18.11.2017 / 19:20