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.
3
votes
1answer
492 views
Memoized Collatz sequence
Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out ...
4
votes
2answers
43 views
Math eval function for Haskell
I recently finished reading Learn you a Haskell for great good!. Even though some topics are a bit over my head (Monads anyone?), I wanted to try my hand at a ...
2
votes
0answers
27 views
Code Generation with Template Haskell
Background:
Recently, I've been working through Coroutining Folds with Hyperfunctions. Don't bail out now if the whole thing makes little sense - it's just the motivation for the existence of my ...
1
vote
1answer
37 views
Mapping and sorting lists of Haskell tuples
I'm a newbie with Haskell and I'm trying to learn the language and its idioms while working through a small data analysis project. The first step of my analysis is to take a very long list of data, ...
2
votes
1answer
41 views
Fizz Buzz in Haskell
Pretty straightforward, I implemented the popular fizz buzz challenge in Haskell.
...
4
votes
2answers
58 views
Convert oOo to Brainfuck and vice-versa
This program was inspired by a Code Golf challenge that I wanted to do properly. It simply converts oOo to Brainfuck and vice-versa.
The oOo language basically uses UPPER / lower case information in ...
1
vote
1answer
17 views
3
votes
1answer
35 views
List union implementation
I'm trying to implement union from the standard Data.List library. I know it's reinventing the wheel, but reimplementing ...
2
votes
1answer
47 views
List of tuples generated through list comprehension
The function returns a list of tuples which is generated through list comprehension:
...
1
vote
0answers
12 views
Expression parser in Haskell using operator precedence table
This is my first non-trivial Haskell project, an expression parser implemented using the Pratt Parser's technique for managing precedence as a layer on top of Parsec. It simply builds an expression ...
3
votes
1answer
54 views
Updates list in haskell to remove duplication
The task in question allows a user to re-rate a film such that only the latest rating from the user should remain in the database.
Initially I solved this problem in a very basic manor?
This was my ...
4
votes
2answers
83 views
4
votes
0answers
38 views
Roman numerals in Haskell
I have written a module that provides some functions for dealing with Roman numerals. I would like some feedback concerning my style, potential performance or elegance improvements, and any ...
3
votes
2answers
46 views
A function determining intervals of values greater than threshold
I wonder if there exists a shorter/more elegant functional programming way than listing all the possible cases. Here, a function that determines positions of beginning/end of subintervals greater than ...
3
votes
3answers
45 views
In a list of pairs, replace snds with median of all snds with the same fst
Given is a list of pairs. I want to replace the second element of all pairs with the median of the second elements of all pairs with the same first element.
For example:
...
5
votes
0answers
26 views
Manual instantiations of common typeclasses for a machine word data type
I've written a data type to represent a word
in the memory of a MIX computer.
A MIX word has a sign bit and five six-bit bytes.
So I created a data type and provided instances
for all the common ...
2
votes
1answer
64 views
Returning the common divisors of two integers
I have written this function that returns the common divisors of two integers. When called recursively 10 times with big integers ranging in 100000000, it takes over 5 seconds. How can I improve it so ...
4
votes
1answer
41 views
Multiple base numbers parser
This code is a Parser that parses numbers according to R5RS.
#b1001 - binary
#o2127 - octal
#h02d - hexadecimal
#d1231 - decimal
3923 - decimal
It is ...
5
votes
1answer
97 views
CIS194: Risk!-style “battles”
After reading LYAH and using RWH as a reference, I've been doing the exercises from CIS194, which is often suggested to beginners on irc://freenode.net/#haskell and ...
3
votes
2answers
41 views
Finding heaviest path through triangle
I am doing Project Euler problem 67 which involves finding the heaviest path through a triangle of integers like this one (this is a smaller version from an earlier problem)
...
2
votes
0answers
34 views
Haskell zmq & protobuf message forwarding
I wrote a test program (and first "real" Haskell program!) that receives a zmq request on 1 socket, and forwards part of that message to another socket.
There are a 2 things I specifically don't ...
4
votes
1answer
56 views
soundex implementation
The soundex algorithm maps several spellings of a name to a 4 character term. (hopefully mapping all different transcriptions to the same term) The steps as described in Introduction to information ...
6
votes
1answer
57 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 ...
5
votes
1answer
36 views
Log messages parser
I've been studying Haskell for some time, but I have never used it for real. So, I started following the CIS 194 Course from UPenn. I resolved the second homework but I'm not fully satisfied with the ...
7
votes
2answers
73 views
Simple command-line password generator
I'm very new to Haskell, I've read most of learnyouahaskell.com and played around with some simple things, but this is probably the most 'complicated' bit of Haskell I've written so far. I have an ...
4
votes
1answer
56 views
Converting image size from Maybe (Int, Int) to (Float, Float)
I have a function that returns size of an image IO (Maybe (Int, Int))
It would be nice to convert it to float tuple beautifully.
I am sure there must be a better ...
5
votes
1answer
70 views
Project Euler problem 11, finding adjacent numbers with the greatest sum
The full description of the problem to solve can be found here. The code I have written works fine but seems extremely verbose for what it's doing, I'm not sure if list comprehensions are meant to be ...
6
votes
1answer
56 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 ...
1
vote
1answer
27 views
Convert a string into an R vector expression
Problem: Given a arbitrary string, split by a given regex and format into an R vector expression. E.g. Convert "a..,b..,c,d" into 'c("a","b","c","d")', when the given regex is "[.,]+".
Solution in ...
8
votes
2answers
381 views
Resistance is futile, Resistors have been dispatched to model your Resistance
Since it was getting boring to always do OOP Languages I decided to dabble in the functional realm of programming.
For that I chose the narrowly missed community-challenge by Edward: Resistor Mania, ...
4
votes
1answer
68 views
GitHub API client
Here is my Haskell program designed to list all of my GitHub repos along with their descriptions and languages via the GitHub JSON APIs:
...
6
votes
1answer
36 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:
...
3
votes
1answer
25 views
Embedding a Text -> Maybe MyDataType function in a Parser to parse JSON into a custom data type
I have these types:
...
3
votes
1answer
68 views
Using Wreq and Lens libraries to query Prosper for account info
I am trying to create a program to manage my Prosper investments for me as an intro to Haskell project. I created a post a few weeks ago for some of the simpler backend calculations: Recommend Next ...
11
votes
2answers
95 views
Vigenère Cipher in Haskell
I wrote a Vigenere cipher in Haskell, but I feel like I way overdid it. This is the second version of the program that allows custom cipher tables, removing the limit of just having letters from A to ...
8
votes
1answer
84 views
My first Haskell: dice rolling
Yesterday morning I decided to stop procrastinating and start learning me some Haskell.
So far I've made this, which is a simple cli 'dice rolling' utility that can be used like:
...
1
vote
0answers
49 views
5
votes
1answer
49 views
Haskell CodeEval Beautiful Strings
Problem Definition :
When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the ...
6
votes
1answer
56 views
Recommend Next Note Purchase
I have just started trying to learn Haskell and tried to think of a practical, but simple problem to try and solve. I have a strong background in C, but am just beginning to dip my toes in the world ...
5
votes
1answer
49 views
Haskell compositor
This is a concept for a compositor. It would help me if you could review how well I expressed my ideas into the functional language.
I first divide everything in an areas that each window covers ...
11
votes
1answer
110 views
The ugly Christmas tree, Haskell style
Inspired by a few inverse tree ascii art F# questions, I wanted to give it a shot in Haskell.
As seen in the linked questions, the resulting program reads an Int ...
4
votes
2answers
90 views
Function that produces \$a^nb^nc^n\$
I'm trying to write a function that produces an infinite list containing strings of the form \$a^nb^nc^n\$.
My first idea was to do it using comprehensions.
...
4
votes
4answers
102 views
A “map” function that alternates between two mapping functions
I am trying to solve following problem in Haskell using recursion:
Define a recursive function funkyMap :: (a -> b) -> (a -> b) -> [a] -> [b] ...
8
votes
1answer
67 views
Haskell CodeEval FizzBuzz
CodeEval FizzBuzz
Quick Description:
Take 1 command line argument of a file-path. This file will contain
test cases formatted as such 3 space separated numbers per line. For
numbers ...
3
votes
1answer
46 views
HackerRank: Counting Sort 1
I've just solved this challenge, though I feel that there is a problem with stack growth or something because the 5th testcase has a runtime error
...
10
votes
1answer
63 views
Printing patterns in Haskell
Write a function Int -> Char -> Char -> [String] that will create the appropriate pattern.
For example: ...
12
votes
2answers
118 views
“Vc” as in Vancouver, or Valencia?
It is common to shorten city names when writing, or at least in Sweden.
"Göteborg" (Gothenburg) is often referred to as "Gbg"
"Uddevalla" is commonly written as "Ua"
"Trollhättan" is often written ...
2
votes
1answer
64 views
Counting dashes in numbers
I have written my very first Haskell module and I feel that the code can be improved based on the simplicity of the problem I am solving. Do you have any suggestions?
Problem statement:
...
5
votes
1answer
66 views
Project Euler Problem 54 in Haskell
I wrote an implementation in Haskell for Project Euler Problem 54:
The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated ...
5
votes
1answer
57 views
Double every 2nd item in a list
Some exercise required me to write a piece of code to double every second item in a list. My first thought was just using cons and I came up with the following:
...