Category : haskell

For example you may see Python code such as xss = [[-0.104],[-0.047],[-0.046]] yss = [[0.183, 0.366, 0.456], [0.971, 0.156, 0.856]] answers = [sum([xs[0] * y for xs, y in zip(xss, ys)]) for ys in yss] print(answers) (Here this code is taken from https://stackoverflow.com/a/63442625/13860599) Or Haskell code such as cartesian :: [[a]] -> [[a]] cartesian [] ..

Read more

This is a simple python code that takes an input and matches it with a frequency array to check if it belongs to the English language or Portuguese language. strinp=input() arr=list(strinp) eng_freq = [8.12,1.49,2.71,4.32,12.02,2.30,2.03,5.92,7.31,0.10,0.69,3.98,2.61,6.95,7.68,1.82,0.11,6.02,6.28,9.10,2.88,1.11,2.09,0.17,2.11,0.07] pt_freq = [12.21, 1.01, 3.35, 4.21, 13.19, 1.07, 1.08, 1.22, 5.49, 0.30, 0.13, 3.00, 5.07, 5.02, 10.22, 3.01, 1.10, 6.73, 7.35, ..

Read more

I am used to working with Python and fairly new to Haskell. I was wondering how strings are left/right alinged in Haskell and if there exist equivalent functions to the following Python functions in Haskell: str = "Hello stackoverflow." # Printing a left aligned string print (str.ljust(40)) # Printing a right aligned string print (str.rjust(40)) ..

Read more