Skip to main content

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.

Filter by
Sorted by
Tagged with
7 votes
1 answer
249 views

UPenn CIS194: Credit Card Validation (Homework 1 Part 1 Tests)

I am working through the UPenn CIS194 lectures and homework assignments in an effort to learn more about Haskell. The first part of the first homework is focused on validating credit card numbers. ...
jeyoor's user avatar
  • 173
7 votes
1 answer
154 views

Find the center of a red dot of an image in Haskell

I try to find the center of all the red pixels contained in an image using Haskell and repa. My problem is, that the code is ...
Erich's user avatar
  • 464
7 votes
1 answer
6k views

String splitting function in Haskell

I need to write a function which selects a run of repeated characters from the start of a string, with the run comprising at most nine characters. ...
August's user avatar
  • 225
7 votes
1 answer
777 views

Shortest Path (BFS) through a maze

Background I have decided to use this year's Advent Of Code to learn Haskell. I feel like I vaguely understand the language and can solve most of the problems with relative ease. However, the code I ...
Bart Platak's user avatar
7 votes
1 answer
113 views

Fraction or integer parser

Question How can the following implementation of fractionParse be made less ugly? (Preserving unreduced numerators and denominators is supposed to be a feature---...
jacg's user avatar
  • 173
7 votes
2 answers
906 views

Bucket sort in Haskell

As a first step in learning Haskell I am solving this problem, which involves finding the Rith-ranked numbers, given some input list and many Ri. In an imperative language I would make a zeroed array ...
stewbasic's user avatar
  • 203
7 votes
1 answer
410 views

A beginner's brainfuck interpreter in Haskell

I am rather new to haskell, and could use some feedback on my code and the decisions I had to make. In my previous project, I made a JSON parser, but relied heavily on guidance from a university ...
el_micha's user avatar
7 votes
1 answer
116 views

First SO chat message in Haskell followup

I have wrote an application which asks for the user id, and returns a link to the first available chat message: Output Enter user id: 322395 Fetching data... http://chat.stackoverflow.com/...
Afonso Matos's user avatar
7 votes
1 answer
422 views

Graham scan implementation in Haskell

It looks like this is a really classical question, but I'd like to ask it one more time as all those solutions look quite long and complicated for me (maybe because I am dumb :) ) So this is a ...
daniil's user avatar
  • 163
7 votes
0 answers
85 views

Feedback on LZSS implementation

Recently, I've been trying to get back into Haskell, so I tried coding up a LZSS implementation. I realize this is much more easily implemented imperatively, but I wanted to challenge myself. The last ...
greenjaed's user avatar
  • 171
7 votes
1 answer
154 views

BingWallpapers: Fetches and applies the image of the day from Bing as the wallpaper

I have written a small desktop program nabeelomer/BingWallpapers in Haskell. This is my first time writing Haskell. I was wondering how I can make the code use more functional programming features/...
1 -_-'s user avatar
  • 71
6 votes
2 answers
2k views

Hamming distance between two strings

I wrote this module to find the Hamming distance between two strings. (It's a problem from exercism.io's Haskell track.) As I saw it, the problem has two distinct ...
Josh Friedlander's user avatar
6 votes
3 answers
723 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, ...
hasnoob's user avatar
  • 137
6 votes
1 answer
95 views

Generating prime candidates

I'd like to generate an infinite list of prime candidates of the form 6k±1, but I'm looking for the fastest possible solution. Currently I have this: ...
rubik's user avatar
  • 503
6 votes
2 answers
871 views

Simple number-guessing game in Haskell

I've been learning Haskell for 2 weeks now which is I'm very new to it. I would like to have feedback on what is good/bad about my code and how it could I improve in learning functional programming ...
JHV's user avatar
  • 63
6 votes
1 answer
2k views

Haskell BigInt addition

I have a function add that adds two lists of integers: add [1, 2] [4, 5, 8] == [4, 7, 0] add [9, 8, 9] [1, 3] == [1, 0, 0, 2] ...
Matthias Braun's user avatar
6 votes
3 answers
453 views

Project Euler problem 92 (sequences formed by the sum of squares of digits) in Haskell

I made the following program in Haskell to solve Project Euler's problem 92. The program works (i.e. the solution it yields is correct), but it's not exactly the fastest in the world. The problem is: ...
Ben's user avatar
  • 273
6 votes
4 answers
2k views

Get Nth item from end of list

I am starting out in Haskell and thought I would try to make a function that got the index (nth) from the end of the list. So getNthFromEnd 5 [1..10] would equal 5 ...
Harry's user avatar
  • 163
6 votes
2 answers
167 views

Infinite list of strings containing 'a'

I was assigned to write a piece of Haskell code that makes an infinite list containing increasing numbers of 'a's. My first thought was to write it as a list comprehension like this: ...
Michael Chav's user avatar
6 votes
3 answers
589 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 ...
castle-bravo's user avatar
6 votes
2 answers
3k views

Haskell Collatz Conjecture

In an attempt to begin properly programming in Haskell, I wrote two functions for calculating numbers and sequences with Collatz's conjecture. I also commented the program quite a lot, because it ...
joshhartigan's user avatar
6 votes
3 answers
1k views

Very simple in-memory database

I've implemented a very simple in-memory "database" just as an exercise. I wanted to see if there's anything obvious I should be doing that fits more of the Haskell way of doing things. ...
Chris Bolton's user avatar
6 votes
1 answer
411 views

Simple Credit card validation

I'm a beginner to Haskell (intermediate in web-dev stuff and JavaScript) and I'm not really sure what I could do better for Homework 1 of CIS194 that I'm taking online. The problem statement is as ...
Joshua Rowe's user avatar
6 votes
2 answers
892 views

Bubble sort with counting swaps and comparsions

I have bubble sort code below, which has to count swaps and comparisons of elements. How can it be made more elegant and clear, if it is possible? I think using lots of tuples is not the best way to ...
Shadasviar's user avatar
6 votes
3 answers
726 views

Advent of code: day 1

I am learning Haskell, and what is better than advent of code to do so? The day 1 problem is about adding together the digits that are followed by the same digit from a "circular" string (the next of ...
Boiethios's user avatar
  • 600
6 votes
2 answers
899 views

Basic random password generator

I'm trying to pick up some Haskell skills so thought I'd write a random password generator to get to grips with using IO. It was far trickier than I expected and I ...
boycy's user avatar
  • 163
6 votes
2 answers
483 views

Sorted grep in Haskell

This program implements a sorted grep, that is, a specialized version of grep for sorted files. It uses binary search for the lines of a file that begin with a ...
lbolla's user avatar
  • 388
6 votes
2 answers
926 views

INI File Parser in Haskell

I'm learning Haskell at the moment, and have just written my first useful module - a parser fo INI files. I used Parsec. I'd like to know what can be improved here - or maybe I did some things ...
user avatar
6 votes
1 answer
385 views

Taking n lines from a file which contains m lines, repeating the file lazily if necessary

The desire for such a function came out of the necessity of generating a "source" of Lorem ipsum by repeating over and over the same 50 or something paragraphs of the text. Actually I am ...
Enlico's user avatar
  • 537
6 votes
2 answers
793 views

Simple prime factorization program in Haskell

I'm finally learning Haskell this summer and I have a few questions about conventions. I made a simple prime factorization program which is surprisingly fast, much faster than the ones I made in C++ (...
jet printer's user avatar
6 votes
2 answers
496 views

Simple DFA using the State Monad

I've been getting to grips with some Monads in Haskell recently, and to get some practice I plucked a Mealy Machine out of thin air and decided to implement it using the State Monad (it's a simple ...
hnefatl's user avatar
  • 249
6 votes
3 answers
2k views

Pretty-printed tables in Haskell

Purpose A clean, reusable module to generate pretty tables (much like those in SQL-clients), like so: ...
Phil Kiener's user avatar
6 votes
1 answer
18k views

Filter Duplicate Elements in Haskell

I'm working on HackerRank to try to improve my Haskell skills along side with reading Haskell Programming from first principles. I wrote a program that works, but it seems to time out on large input ...
Eli Sadoff's user avatar
6 votes
2 answers
1k views

String sequence in Haskell

Given a string sequence and a string, the function should output the next string of that sequence. For example, for sequence "abc": ...
Afonso Matos's user avatar
6 votes
1 answer
3k views

Is a List Sorted?

This function checks if a list is sorted. ...
Kevin Meredith's user avatar
6 votes
1 answer
624 views

Poor AI for 2048 written in Haskell

I'm learning Haskell and thought it would be fun to write an AI for the game 2048 in Haskell. In my implementation I got rid of the randomized aspects of the game. This makes the program ...
wvdz's user avatar
  • 253
6 votes
3 answers
2k views

Check whether a string contains exactly one distinct vowel

Over on Stack Overflow, someone asked a simple Haskell question: how to test whether there is exactly one distinct vowel in a given string. To clarify, there can be any number of non-vowel characters, ...
amalloy's user avatar
  • 585
6 votes
1 answer
382 views

Approximating π via Monte Carlo simulation

Inspired by a tweet linked to me by a friend and a Haskell implementation by her for the same problem, I decided to try my hand at approximating the value of π using everything in the Haskell standard ...
Alexis King's user avatar
  • 3,172
6 votes
1 answer
580 views

1 or 2 Player CLI Tic-Tac-Toe

I wrote a simple tic-tac-toe program in Haskell. It runs on the command line, has a one and two player mode, and implements a minimax algorithm when you play against it. I'm used to writing proper ...
Mark Karavan's user avatar
6 votes
2 answers
426 views

Beta Reducer in Haskell

This is my first Haskell application, so any non-name-calling tips will be taken extremely well! It is just a beta reducer: ...
MaiaVictor's user avatar
  • 1,101
6 votes
1 answer
112 views

N Nested squares

The excercise is to print n nested squares. The nested squares are given as input by the user. Example output for n = 4: ...
DobromirM's user avatar
  • 1,123
6 votes
1 answer
247 views

Cracking Caesar Cipher

I'm new to Haskell, so I wrote a program to crack Caesar Ciphered text for practice. The program calculates the frequency of each letter in the input, and then checks to see which shift minimizes the ...
mthra's user avatar
  • 63
6 votes
2 answers
123 views

Command line tool, listing video files on a local drive

Explanation I started learning Haskell about a month ago. As an exercise, I recreated a little command line tool, which I had previously written in PowerShell. In the current state, it displays a ...
user avatar
6 votes
1 answer
96 views

Haskell Convert 1-800 Numbers

This little app converts 1-800 numbers (with letters) to actual numbers. I'm very frustrated by the insertDashes function as it's very brute force. I'm sure there's a far more elegant solution. I'd ...
Jim Wharton's user avatar
6 votes
1 answer
403 views

Toy Forth interpreter

I've been reading too many papers and writing too little code. These are my first 300 lines of Haskell: ...
Vincent Goossens's user avatar
6 votes
1 answer
654 views

New Haskell package: OpenCL

I am developing a high level OpenCL binding in Haskell, and I need peer-review and testing. It currently only gets platform and device info from OpenCL. I have lots of functions that only change the ...
Zhen's user avatar
  • 265
6 votes
1 answer
567 views

Read HTTP header from TCP socket

I'm growing a web server in Haskell that interfaces with TCP sockets using network. To read the HTTP header of the client's message, I use the following function: ...
Matthias Braun's user avatar
6 votes
1 answer
245 views

Generating smooth numbers in Haskell

I wrote a smooth function that returns a list of all smooth numbers below a certain limit from a list of prime: ...
Vincent's user avatar
  • 335
6 votes
2 answers
244 views

Imperative Sieve of Eratosthenes using destructive updates in Haskell

I've implemented the prime sieve of Eratosthenes in Haskell using a mutable array of unboxed Bools instead of the usual pure and immutable datastructures. My main concern with this code is speed. For ...
user3493525's user avatar
6 votes
1 answer
314 views

Convert data back-and-forth between CSV files and pretty-print

I wrote a script to convert CSV files in human readable format and vice versa. Human readable format is achieved like so: ...
user2740's user avatar
  • 409

1 2 3
4
5
22