Tagged Questions
2
votes
0answers
22 views
A solution to the AST Typing Problem
Expression trees are the bread and butter of functional programming but when it comes to adding additional information to an established tree it can be difficult to incorporate such changes without ...
2
votes
1answer
39 views
Folding with trees
I was trying to implement a foldTree function to generate a balanced binary tree from a list of values using foldr (Question 2 ...
2
votes
1answer
56 views
Removing duplicates from list and filtering non-letter characters
I'm just starting out in Haskell and have been set an assignment for uni where I have to create a reverse index of words in a text file and find what line numbers they appear on. I also have to remove ...
4
votes
1answer
33 views
Counting items in categories
I'm an experienced programmer that also has a little experience with functional programming, although mostly theoretical (as in hobby-level reading and very minor projects).
I recently decided to ...
5
votes
2answers
71 views
Decomposing bitfield with Haskell: is recursion the only way to do this?
Here's a program to take a bitfield like 7 and decompose it into the flags [1,2,4].
Ignore that the algorithm for doing this doesn't use bit shifting/is stupid.
Problems: it seems like I have to have ...
5
votes
1answer
49 views
Conversion from decimal to negabinary and vice versa in Haskell
Recently I set about to writing conversion functions in Haskell between decimal and negabinary. I tried to write them in as much functional a style as possible, also aiming at brevity. Below I present ...
10
votes
1answer
135 views
(How) should I avoid writing procedural code in Haskell?
I'm trying to implement a left leaning red black tree as described here. This is their snippet for insert
...
2
votes
2answers
182 views
“Hell Difficulty” Haskell Fast & Hard
I'm a complete neophyte to Haskell with only a smidge of FP experience – I did some Racket programming academically and have written some semi-FP JavaScript professionally, but now I'm trying to learn ...
6
votes
1answer
121 views
Better or more idiomatic way to apply a sequence of functions in Haskell
This is one of my Haskell solutions to a variation of the N-Queens problem, where the queens can move like knights in addition to their normal moves. It has been optimized somewhat to avoid ...
0
votes
0answers
111 views
Optimizing my Quadratic Sieve, with advice on style?
I'm still new to Haskell, and I'd like others' opinions on optimizing my basic quadratic sieve, in addition to feedback on the code's clarity and functional style.
The ...
2
votes
1answer
103 views
Haskell Bencoded Dictionary Parser
I have been working on a Bencoded string parser in order to improve my knowledge
of Haskell. After running the code through hlint, I still have a few questions:
As I noted in the comments, the key ...
3
votes
0answers
150 views
How to improve readability and memory footprint of this haskell script?
I have this small haskell script that I wrote some time ago to parse a set of financial CSV files to produce other CSV files. I've recently had a problem with large input files (around 300Mb) that I ...
1
vote
1answer
185 views
4
votes
2answers
1k views
Palindrome test in Haskell
I am new to Haskell and, coming from a OO/procedural programming background, I want to make sure my code follows the functional way of doing things. I built this short module to test if a given string ...
1
vote
0answers
140 views
Space and time complexity of operation on lists
I'm new to programming and even more new to Haskell. Below is a little tid-bit I wrote that operates on a bunch of lists. I am wondering if someone would be kind enough to walk through the function ...
4
votes
2answers
97 views
Is there a way to simple Haskell class instance?
I define a Pixel data with different size like this.
...
1
vote
0answers
75 views
3
votes
1answer
139 views
Help make nested folds look less terse
My Haskell set/map/list folds often become terse and difficult to read. I'm looking for tips on how to make my functional code easier to follow.
I'm working around a bug/feature in a plotting ...
13
votes
4answers
2k views
How to shorten this terrible HTTP header parser?
I am trying to read a line ending in \r\n from a Handle. This is an HTTP header.
I’m fairly new to functional programming, so I ...
4
votes
2answers
185 views
Writing an infinitely running( while(true) { } ) user input function in haskell
I'm trying to implement a lexer in Haskell. For easy console input and output, I've used an intermediate data type Transition Table.
...
7
votes
2answers
208 views
Naive Bayes classifier
I just started learning Haskell, and I must say it is unlike anything else. As my first not-entirely-trivial piece of code I tried to write a simple Bayes Classifier. It is in two parts, a classifier ...
4
votes
1answer
420 views
Simple Haskell key value file store
As an exercise in learning Haskell, I implemented a simple key value store, where you can put and get values (as ByteStrings). (For reference this is inspired by ...
7
votes
4answers
430 views
Can I make this code more Haskelly?
I am very new to functional programming. I wrote this program where the user can enter an integer and it prints the factorial. If the user enters a negative integer or not an integer at all, it'll ...
7
votes
4answers
615 views
Finding the sum of all the multiples of 3 or 5 below 1000, using list comprehension
I'm trying to compare my own implementation with another solution of Project Euler problem #1, which uses a list comprehension:
...
6
votes
1answer
117 views
Chaining method calls and “bubbling” the results
I need a way to build up a sort of stack of places to search for an item.
What I would like to do is to have each layer searched for an item, and if it is found at that level, then it should be ...
4
votes
2answers
432 views
Enclosing Circle Problem implementation in Haskell
I implemented the algorithm by Pr. Chrystal described here in Haskell so could someone please tell me: Do i have implemented this algorithm correctly?
Initial calling of findPoints takes the first and ...
3
votes
1answer
169 views
Most elegant approach to writing list renumbering function
I'm writing a function with the following signature:
(Ord a) => [a] -> [Int]
It's semantics is to find an order-preserving mapping from list of objects to ...
14
votes
1answer
458 views
Converting simple markup to HTML
This is going to be rather long and generic, so apologies in advance.
I've been reading a lot about Haskell lately, but I've never really programmed anything with it beyond simple experiments in ...