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
vote
0answers
38 views
Dynamic programming with Project Euler #18
I just wanted to get an opinion on my dynamic-programming Haskell implementation of the solution to Project Euler problem 18.
The Problem:
By starting at the top of the triangle below and moving ...
2
votes
0answers
42 views
Code from “Write Yourself a Scheme in 48 Hours” tutorial
I recently went through this Haskell tutorial.
I'd be interested in any thoughts or comments at all, in terms of improving the structure, order, haskell conventions, or that long, kind of ugly eval ...
1
vote
1answer
23 views
v2 - Adding a duplicate entry randomly into a list in haskell using random monad
Next version of Adding a duplicate entry randomly into a list in haskell using random monad
I wrote this trying to set up a Haskell testcase. The aim is to take a list and add a single duplicate from ...
3
votes
2answers
52 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 ...
4
votes
2answers
59 views
Deciding whether a list of sum types is homogeneous
I ran into a problem recently where I had to decide whether a set of sum types was homogeneous (all the same). In itself, this is a pretty simple problem. However, there were a few complicating ...
4
votes
1answer
17 views
Adding a duplicate entry randomly into a list in haskell using random monad
There's a new version of this as v2 - Adding a duplicate entry randomly into a list in haskell using random monad
I wrote this trying to set up a Haskell testcase. The aim is to take a list and add ...
1
vote
1answer
30 views
haskell batch file renamer
This is my first ever haskell, please tell me how I can improve the structure of this simple tool (note depends on MissingH):
...
0
votes
2answers
50 views
Function Composition: $ versus `.`
Learn You a Haskell offers the findKey function:
Here's the book's implementation:
...
1
vote
1answer
25 views
Substitution Cipher in Haskell
Learn You a Haskell presents the Caesar Cipher:
The Caesar cipher is a primitive method of encoding messages by
shifting each character in them by a fixed number of positions in the
alphabet
...
10
votes
2answers
103 views
Processing text files for data extraction and analysis
I started learning Haskell to see if I can use it at my job. A lot of my work is processing text files for data extraction and analysis.
For my first test, I added a counter at the end of each line ...
2
votes
1answer
24 views
Implementing `zip4` in Haskell
Learn You a Haskell explains zip4:
--ghci> zip4 [2,3,3] [2,2,2] [5,5,3] [2,2,2]
-- [(2,2,5,2),(3,2,5,2),(3,2,3,2)]
...
1
vote
3answers
73 views
Efficient Collatz sequence analysis
I'm new to Haskell, and I'm wondering why my programs are so slow compared to other languages.
Haskell, 6 seconds (x64, -O2):
...
5
votes
1answer
23 views
Module representing rational numbers
Taking inspiration from SICP Exercise 2.1, I decided to implement a module in Haskell for rational numbers.
Some of my concerns include:
Is this idiomatic Haskell?
Besides ...
3
votes
2answers
37 views
Implementing Haskell's `insert`
Learn You a Haskell shows the insert function.
insert takes an element and a list of elements that can be sorted and
inserts it into the last position where ...
0
votes
1answer
27 views
Implementing Haskell's `union`
Learn You a Haskell shows the union function:
union also acts like a function on sets. It returns the union of two
lists. It pretty much goes over every ...
1
vote
1answer
20 views
Implementing Haskell's \\ (Set Difference)
Learn You a Haskell presents the \\ function.
\\ is the list difference function. It acts like a set difference,
basically. For every element in the ...
1
vote
1answer
21 views
Implementing Haskell's `delete`
Learn You a Haskell shows the delete function.
delete: deletes first occurrence of item
...
5
votes
3answers
446 views
Implementing Haskell's `unwords`
Learn You a Haskell explains the unwords function.
$unwords ["hey","there","mate"]
"hey there mate"
Here's my implementation.
...
2
votes
1answer
24 views
Implementing Haskell#words
Learn You a Haskell shows the words function.
words and unwords are for splitting a line of text into words or
joining a list of words into a text
Example:
...
1
vote
1answer
17 views
Implementing Haskell#break
Learn You a Haskell demonstrates the break function:
breaks it when the predicate is first true.
Example:
...
1
vote
1answer
33 views
Implementing Haskell#lines
Learn You a Haskell shows the lines function:
It takes a string and returns every line of that string in a separate list.
Example:
...
1
vote
2answers
35 views
Haskell's `partition`
Learn You a Haskell mentions the partition function:
partition takes a list and a predicate and returns a pair of lists.
The first list in the result contains ...
1
vote
1answer
27 views
isPrefixOf & isSuffixOf
Please review and suggest improvements for my isPrefixOf implementation.
...
2
votes
1answer
36 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 ...
3
votes
1answer
27 views
2
votes
2answers
44 views
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 ...
2
votes
1answer
36 views
2
votes
3answers
327 views
1
vote
1answer
46 views
Haskell#concat Implementation
Here's how I implemented concat - flattens a list of lists into just a list of elements.
...
2
votes
1answer
36 views
Split list into groups of n in Haskell
I need to split a list into equal sublists, e. g [1..9] split into groups of 3 will be [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. I have ...
3
votes
2answers
39 views
Implementing Transpose
I'm implementing transpose in Haskell.
-- transpose [[1,2,3],[4,5,6],[7,8,9]]
-- [[1,4,7],[2,5,8],[3,6,9]]
Please give it a ...
3
votes
2answers
44 views
1
vote
1answer
70 views
Idiomatic IO in Haskell
I'm working through Yet Another Haskell Tutorial. One of the exercises is to prompt the user to enters numbers, entering a 0 to quit. The program should then both sum and multiply all the given ...
1
vote
1answer
38 views
Improving a Haskell FizzBuzz Solution
I wrote a solution to the popularized FizzBuzz problem in Haskell to see how a functional solution looks. I'm more or less happy with my solution, except for the definition of ...
3
votes
1answer
46 views
Implementing nub (distinct)
I've implemented the following nub' or "give distinct elements of list" function:
...
2
votes
1answer
47 views
Function with excessively complex “where” clause
I'm writing a program to differentiate functions (perform basic calculus) in Haskell. The program works, but there's one function that looks very ugly to me:
...
3
votes
1answer
35 views
How to simplify Regex with Data.Text?
This function tells that elements of content either (maybe) match regexes that you like or match regexes that you don't like.
This messy code requires ...
4
votes
1answer
85 views
Aho-Corasick string matching in Haskell
I implemented Aho-Corasick string matching in Haskell. It is a purely functional implementation compared to many other implementations.
The input to build an automata is ...
4
votes
2answers
71 views
replacing every pair in a list
I need a function (I named it applyToEveryPair) that works on lists, e.g. [x0,x1,x2,x3,...], and uses a function
...
2
votes
1answer
53 views
What's more idiomatic in Haskell?
I'm writing the data structures for my program (a toy compiler), and I'm trying to understand what's the best way to define the AST:
Current code
...
11
votes
2answers
222 views
Blackjack in Haskell
This is my first attempt at creating a game in Haskell, and I would greatly appreciate some feedback.
Here is Main.hs:
...
5
votes
1answer
244 views
Revised: AI for 2048 in Haskell
This is a revised version of an AI for the game 2048, written in Haskell.
Link to original thread: Poor AI for 2048 written in Haskell
I think this version is a lot cleaner, thanks to the tips from ...
3
votes
1answer
44 views
6
votes
1answer
98 views
6
votes
1answer
206 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 ...
2
votes
2answers
35 views
Implement a fold-like Function in Haskell
Let's say I need to write a function that applies a function to each item in a List, and then appends it to an accumulator. When the List is empty, return the accumulator.
...
5
votes
2answers
63 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
55 views
BFS implementation that walks a tile-based field
I wrote a BFS implementation that walks a tile-based field. It takes a function that should return true for walkable tiles and false for walls. It also takes the start and end points. It currently ...
10
votes
1answer
147 views
Probably unneeded returns
This is my first "useful" Haskell program. It's invoked with filenames as arguments where the last filename is the destination to which the content of all other files will be concatenated. As far as I ...