Questions tagged [haskell]
Haskell is a purely functional programming language, featuring static typing, lazy evaluation, and monadic effects. The primary implementation is GHC, a high-performance compiler with a runtime supporting many forms of parallelism and concurrency.
1,080 questions
0
votes
0
answers
51
views
Augment vi editing mode in haskeline by implementing the ; and , commands
haskeline is a reimplementation in haskell of the GNU Readline library (the one that by default allows you to delete the word you just typed on your shell's command line by pressing Ctrl+w, for ...
3
votes
2
answers
194
views
Pattern Finding In Lists of Strings (2d Char Array), Advent of Code Day 04 Solution
This is part 2 of Day 4 of 2024's AoC: The problem is as follows:
It's an X-MAS puzzle in which you're supposed to find two MAS in the shape of an X. One way to achieve that is like this:
...
5
votes
3
answers
307
views
HackerRank, Haskell simple "compression" algorithm
The question asked is very straight-forward and is simple enough to solve. What I am looking for is that hopefully I can get some understanding for using the constructs and built-ins of the Haskell ...
8
votes
1
answer
145
views
Haskell 2-player TicTacToe terminal game
I want to get better at functional programming so I started with this simple 2-player TicTacToe game. Next I want to add a simple min-max algorithm to make it a 1-player game, but before that I'd like ...
2
votes
0
answers
85
views
Last Stone Weight Problem in Haskell Using `fold`
A previous solution of this code has been posted on Code Review before.
This solution is more complicated then that one, but more performant (see the below)
Why is this another Question instead of a ...
1
vote
1
answer
236
views
Haskell code optimization for short Pi approximator
Very new in Haskell, as a first easy program I went for an old algorithm of mine to approximate pi by counting points within a circle. The snippet below is what I could get working. I had quite an ...
4
votes
2
answers
774
views
Performance of Haskell prime sieve
I have this code, which is a pseudo-Sieve of Eratosthenes for generating primes:
...
5
votes
1
answer
184
views
Ackermann-Péter function call count using Writer monad
I'm quite new to Monads and I tried add function call counting to the Ackermann function code. The goal was simplicity, not performance. I want to have code review on the ...
2
votes
1
answer
166
views
Count islands in a binary grid
This is the No of Island code challenge.
Please review my implementation in Haskell. I know there must be some better way of doing this.
Given an m x n 2D binary grid grid which represents a map of '...
2
votes
2
answers
131
views
Slow Bioinformatics algorithm - Clump finding algorithm in Haskell
I'm working on the famous clump finding problem to learn Haskell. Part of the problem involve breaking nucleotide sequences, called kmers, into subsequences as follows:
...
4
votes
1
answer
268
views
Two Sum Implementation on Haskell Brute Force and Optimized approach
Two Sum Problem:
Given an array of integers A and an integer K return True if there are two elements two elements xi, xj (i != j) such that xi + xj = K. Return False otherwise.
I am implementing the ...
0
votes
1
answer
161
views
Unit testing and alternative to mocking in Haskell
Let's say you have a simple pure function that applies a discount of 30% if the total price of a list of Items is over 30.00 (let's not delve into the fact that I'm ...
2
votes
1
answer
108
views
Meta Collatz Sequence
Context
Chapter 6 of Learn You A Haskell contains a function called chain, which outputs the Collatz sequence of a given input.
(In short, it takes a natural number....
2
votes
0
answers
117
views
Source map file generator
I'm trying to use this library in my haskell program to generate a source map file, but getting some performance issue. The size of the mapping file generated was about 30M bytes, and it took almost ...
2
votes
1
answer
163
views
Project Euler 11 Haskell - Largest product in a grid
Intro
I have been learning haskell and functional programming using random Project Euler problems. Currently, I have solved Problem 11.
What is the greatest product of four adjacent numbers in the ...
3
votes
1
answer
150
views
Rendering a cross in ASCII art
I've recently tried to write my functions by using composition. But this one, renderCross' is especially difficult to convert fully. How would I write this ...
3
votes
1
answer
181
views
A simple hangman game in Haskell
I just finished a course of functional programming in uni and continued to study Haskell because I found it very interesting! I made a simple hangman game and would like to hear any of your thoughts ...
2
votes
1
answer
178
views
Simple Manual Lexer in Haskell
As a beginner exercise, I made small manual lexer that recognizes three types of inputs:
integers: /[-]?[0-9]+/
strings, inside double quotes, with backslash ...
1
vote
1
answer
112
views
Haskell solution to Day 2 problem of Advent of Code '21
I won't restate the problem in full, but in a nutshell you have to parse a file with a "direction" and a "magnitude", for instance:
...
3
votes
1
answer
163
views
Function to sum all Armstrong numbers within a range
I've tried to solve a challenge posted on a LinkedIn forum using Haskell - a language I'm still learning the basics of - and, while the code works correctly, I would like to get some feedback on the ...
5
votes
1
answer
353
views
Validate Finnish IBANs
I am currently studying an online course in Haskell and there are no "model examples" of the assignments after finishing them. I'm slowly getting the hang of this, but I'd like some feedback ...
2
votes
0
answers
91
views
Haskell proof checker for FOL with equality
Is this a correct implementation in Haskell of a proof checker for first order logic with equality? I am most interested in if it is correct, and if the functions can be made clearer. I would like it ...
2
votes
1
answer
97
views
Haskell Twitter Thread Follower
I'm learning Haskell and even though I have experience with Functional Programming the Typesystem has been a challenge. I did this yesterday (after like 2 days) and I would like to know whether this ...
3
votes
1
answer
294
views
Efficiently calculating perfect powers in Haskell
I'm trying to calculate perfect powers to solve this code wars challenge: https://www.codewars.com/kata/55f4e56315a375c1ed000159/haskell
The number 81 has a special property, a certain power of the ...
8
votes
1
answer
616
views
Haskell Tic-Tac-Toe (with automation and GUI)
There are already many Tic Tac Toe posts. But as far as I can tell, none of the ones in Haskell are complete with a GUI
Here is my implementation with Gloss. Gist Link for convenience
...