Issue I’m working on a board game where each team must submit an order each turn. To prevent abuse, I’m trying to make a login page, where you can select a team, give the team’s password, and continue to the

Continue reading# Tag: haskell

## [SOLVED] How to pick multiple elements from a list in Haskell

Issue In Haskell I know how I can pick one element from a list by index : head (drop idx myList) But I have a list of indices myIndices (like [1,3,5]) and want to return a list of the elements

Continue reading## [SOLVED] String to IO String (conditional mapM)

Issue I’m working on my first Haskell tool (yay!) and I can’t seem to find a solution to this problem. Most posts discuss converting a String to IO String, but I actually need to do the inverse, since I conditionally

Continue reading## [SOLVED] Problem with showing/outputting Nat type in a function that converts integers to Nats

Issue I am currently learning about types in Haskell, and a given example in the book is to define the data of Nat by two constructors, one for zero, and another one for a constructor. As depicted here: data Nat

Continue reading## [SOLVED] Understanding this matrix transposition function in Haskell

Issue This matrix transposition function works, but I’m trying to understand its step by step execurtion and I don’t get it. transpose:: [[a]]->[[a]] transpose ([]:_) = [] transpose x = (map head x) : transpose (map tail x) with transpose

Continue reading## [SOLVED] How to create all possible combinations of these two lists?

Issue I’d like to take from these two lists to create a list of all combinations, where each combination is also a list. E.g. Given two lists: [1,2,3] and [True, False] Combinations: [(1, False), (2, False), (3, False)] [(1, False),

Continue reading## [SOLVED] Extract from a list elements with indexes given in another list

Issue So I need to extract elements from given list with indexes that are given in another list. Signature supposed to be something like this: search :: [Int] -> [a] -> [a] and the result search [1,3,5] [34,65,67,34,23,43,54] [65,34,43] As

Continue reading## [SOLVED] Haskell: read input character from console immediately, not after newline

Issue I’ve tried this: main = do hSetBuffering stdin NoBuffering c <- getChar but it waits until the enter is pressed, which is not what I want. I want to read the character immediately after user presses it. I am

Continue reading## [SOLVED] Haskell -> Printing sortBy list – error: parse error on input ‘print’

Issue I was trying to run this program on ghci, where it reorders the names in the ascending order of their last names. However, when I run it, I get this error " error: parse error on input ‘print’ ".

Continue reading## [SOLVED] Algorithm to generate all possible arrays of ones and zeros of a given length

Issue How can I generate all possible bit combinations in an array of bits of length n. If I start with all zeros in my array then there are n possibilities to place the first bit and for these n

Continue reading