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.

learn more… | top users | synonyms

4
votes
0answers
22 views

Conways game of life in Haskell

I started with Haskell some months ago, but didn't really use it since then. As a simple training I implemented Conways game of life. What/How could it be improved? ...
1
vote
0answers
9 views

Haskell Sudoku solver using bactracking

This solves Sudoku by using backtracking. Accepts one grid where 0 represents a missing number. Here are some examples: http://norvig.com/easy50.txt The program is quite slow. Input is stdin. ...
3
votes
1answer
29 views

Prime factorization in Haskell

I am a Haskell beginner. Here is my function to find prime factors of a number ...
4
votes
1answer
36 views

Textual representation of a C++ function

I need to create an instance of Show of a somewhat complicated type that represents a C++ function. The "serialization" gives me a Haskell interpretation of the ...
2
votes
1answer
24 views

Haskell marking procedure for non-unique lists

I'm writing a function for generating solutions for a backtracking search problem. To that end, I need to mark an item from a list by removing it from that list, and placing it in a second list. So I ...
4
votes
1answer
28 views

Find the common elements of the lists in a list of lists

Considering the problem: Make a function to find the common elements of the lists in a list of lists. Example: common ( [ [1,2,3,3,5,11], [2,2,2,3,3,5], [2,2,3,3,4,5,6,7,18,19], ...
0
votes
0answers
21 views

Finding triples between 1 and 10 that add to 7 [closed]

I have a list comprehension for finding triples between 1 and 10 that add to 7 but need to remove any duplicates (all but one of (1, 1, 5), (1, 5, 1), (5, 1, 1) should be removed). Can anyone point ...
5
votes
1answer
32 views

L system equations

This is my first program on my second try to learn haskell :) ...
1
vote
1answer
16 views

Rebuilding WAR files in webapps directory

This script cleans up destination directory and copies file into it with new name. Can this intent be expressed more cleanly with shelly? ...
1
vote
1answer
19 views

Levenshtein Distance with Haskell Vectors and Memoization

Is the following an effective way to implement the Levenshtein Distance with Haskell vectors? ...
2
votes
1answer
43 views

DRY Kleisli wrappers with lens

This currently does what I intend: ...
2
votes
1answer
42 views

Hackerrank, Service Lane in Haskell

Problem statement Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any ...
1
vote
1answer
31 views

Palidrome checker in haskell

I decided to avoid the trivial isPalindrome lst = lst == reverse lst and tried writing a method with pattern matching and recursion. ...
8
votes
4answers
671 views

Brute-force perfect-number algorithm

I whipped a reasonably fast brute-force perfect number finding function in Haskell, after seeing a similar thing in mathematica. It works in under 3 seconds when I search up to 1000, but 10000 is too ...
0
votes
0answers
11 views
4
votes
3answers
65 views

Hackerrank, Utopian Tree in Haskell

Problem statement The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the monsoon, when it doubles in height. The second growth cycle occurs ...
5
votes
1answer
68 views

Haskell 99, Problems 1-10 (simple list processing)

I'm just learning Haskell and I wanted to know if I'm going in the right direction with my solving of the Haskell 99 problems. The file of interest is here which I've also reproduced below. ...
5
votes
1answer
109 views

SICP Exercise 1.3: Sum of squares of two largest numbers out of three, Haskell Version

The exercise 1.3 of the book Structure and Interpretation of Computer Programs asks the following: Exercise 1.3. Define a procedure that takes three numbers as arguments and returns the sum of ...
2
votes
1answer
46 views

Huffman code generator in Haskell

This is problem 50 in https://wiki.haskell.org/99_questions/46_to_50. The website has more elegant Haskell solutions, but I wanted to get feedback on how the code I wrote on my own below could be ...
4
votes
2answers
34 views

Network arithmetic, finding the next host for the given

Disclaimer: It's literally the second time I write in Haskell. The purpose of this module is to provide some basic operations with IP addresses (and networks). At the moment I only implemented the ...
5
votes
1answer
85 views

Haskell: Efficient and clear list concatenation

I'm trying to write a function explodeBy: ...
3
votes
1answer
42 views

Print a sequence of n numbers

I have a simple function that takes an Integer n and return a string representing the array from 1..n. ...
1
vote
1answer
41 views

Replacing items in a list

I was wondering why replace is not in base. I thought, it's because it must be easy to implement with standard combinators. ...
4
votes
0answers
53 views

Persistent segment tree

I'm trying to solve this problem. Given a sequence \$B=B_0,B_1,\ldots,B_{N−1}\$ for each query \$(P,K)\$, find the minimum \$S\$ s.t. there are at least \$K\$ entries in \$B\$ that satisfies ...
4
votes
2answers
70 views

Fast way to count the numbers that are divisible by their own sum of digits inside a range

Inspired by this question on Stack Overflow, I wrote a function that returns the length of a list made of numbers that are divisible by their own sum of digits inside a range: ...
2
votes
1answer
49 views

Polymorphic components for graphics and program state

I asked this question on StackOverflow, got some answers, most notably a link to this one, and basing on that I've implemented this: ...
3
votes
2answers
34 views

Implement 'filtering'

The NICTA Haskell Course presents the following function to implement on List: ...
5
votes
2answers
42 views

Checking in four directions for board game win

I have the following code which I would like to simplify in Haskell, although I'm not sure how. I recall that I can use monads to simplify a case chain when the result of the case leads onto a next ...
2
votes
1answer
17 views

UPenn homework 3: histogram

Please see here for the general description. Exercise 3: histogram :: [Integer] -> String takes as input a list of ...
3
votes
3answers
39 views

UPenn Homework 3: localMaxima :: [Integer] -> [Integer]

Please see this question for the general description. Exercise 2: localMaxima :: [Integer] -> [Integer] A local maximum of a list is an element of the list ...
5
votes
2answers
79 views

UPenn Homework 3: skips function

I've started learning Haskell by following along the CIS 194 Course from UPenn. In the first lessons there is talk about wholemeal programming and certain ways idiomatic Haskell code looks like. Now, ...
2
votes
1answer
62 views
2
votes
1answer
155 views

Maybe getting a character from a list of strings

I'm trying to transition from JavaScript to PureScript (a Haskell spinoff that transpiles to JavaScript). For starters I coded this: ...
5
votes
2answers
75 views

Knuth's Word Wrap Algorithm in Haskell

I put together a Haskell function for Knuth's word wrap algorithm. A simplified version of the algorithm is described here. I've already been told that there are certain aspects of my style that are ...
2
votes
0answers
39 views

Implementing insertAt for both [a] and [(i,a)] lists

I've implemented generic insertAt function which inserts value to a list independently from is list indexed or not. Here are some examples: ...
5
votes
2answers
52 views

Another Brainfuck interpreter in Haskell

I came up with the following Brainfuck interpreter in Haskell after thinking about how to represent the program and the memory functionally using zippers to represent current location. This works ...
4
votes
2answers
86 views

Implementation of Graham Scan algorithm in Haskell

Here is an implementation of Graham Scan algorithm for computing the convex hull of a finite set of points: ...
3
votes
1answer
34 views

Attempt at Abstracted YAML Configuration Loader

I've been playing around with writing a simple static blog generator in Haskell (mostly for experience, since there's probably more than a few already made choices that fit my needs). I don't have ...
3
votes
0answers
26 views

Generation and parsing of English numerals (cardinal and ordinal)

I need to use the English numerals (American) in Haskell, so I looked for a library that did it. I have not found one, therefore I developed the program that I am presenting here. There are actually ...
2
votes
1answer
37 views

Sum of multiples of 3 or 5 below N

How do I improve speed of this code? The problem definition is "Find the sum of all the multiples of 3 or 5 below N". ...
1
vote
1answer
46 views

Selection handler for color picker

At some point, I have this function which updates a color picker according the the mouse position, according to whether the user clicked a mouse button and according to its previous state: ...
1
vote
0answers
34 views

Traversing game state space : more search leads to bad results [closed]

I am trying to solve a problem which i think is TSP on a 2-D grid. So, i am trying to get the best result that i can. However, looking ahead 1 step is producing ...
2
votes
0answers
89 views

Small web service using scotty

I'm writing a small tool that allows to manually protocol dial-in-actions. That means a user can say he dials in to a site or he dials out of a site. (What this means is not important for the sake of ...
1
vote
1answer
47 views

Beauty and the Strings in Haskell

I decided to make a solution in Haskell to a problem that I found on another post here at CodeReview (link: The Beauty and the Strings) I would like suggestions on how to improve letterFreqs. I have ...
0
votes
2answers
72 views

Fast sums of power algorithm

This code reaches time limit on 1 test case, solving this challenge. The approach that I'm using is from the book Algorithms Functional Programming Approach, which is a backtracking depth searching ...
3
votes
1answer
43 views

Generating all size-k consecutive subsets in Haskell

I am interested in splitting any list into consecutive subsets based on a k-value. For example, [1,2,3,4,5] splits into ...
1
vote
0answers
21 views

Implementing `repsep` Parser

I wrote the following repsep parser. It consists of (where ~ means followed by) and + ...
4
votes
3answers
68 views

Prime factorization of an integer

I have just started learning functional programming (Haskell) for fun after using imperative languages my whole life. I am looking for quick and simple tips from pros on how the particular code I just ...
3
votes
1answer
111 views

Haskell Luhn Algorithm

Trying to get to grips with Haskell. The problem is taken from here. ...
6
votes
3answers
111 views

Sieve of Sundaram for Project Euler 7

This is a sequel to my previous question: Sieve of Sundaram for Project Euler 7: Python implementation slower than C++ and R I am trying to implement the Sieve of Sundaram in various languages to ...