Snipplr
http://snipplr.com/language/haskell/tags/algorithm
Recent snippets posted on Snipplr.comen-usFri, 27 Feb 2015 17:02:04 GMT(Haskell) Haskell 99 Problems, numbers 1 through 9 - rtperson
http://snipplr.com/view/58509/haskell-99-problems-numbers-1-through-9/
I had originally started these problems from #10 (Run-length encoding). I went back and did 1-8 for completeness. ]]>Thu, 08 Sep 2011 00:23:54 GMThttp://snipplr.com/view/58509/haskell-99-problems-numbers-1-through-9/(Haskell) Haskell 99 Problems - Number 20, Arrowed! - rtperson
http://snipplr.com/view/58144/haskell-99-problems--number-20--arrowed/
problem 20, (*) Remove the K'th element from a list
*Main> removeAt 1 "abcd"
"acd"
Trivial using a pure function. A bit more challenging if you use this problem to work up your Arrow-fu. ]]>Thu, 25 Aug 2011 01:54:30 GMThttp://snipplr.com/view/58144/haskell-99-problems--number-20--arrowed/(Haskell) Haskell 99 Problems - Number 18 and 19 - rtperson
http://snipplr.com/view/58064/haskell-99-problems--number-18-and-19/
Problem 18: Extract a slice from a list.
Given two indices, i and k, the slice is the list containing the elements between the i'th and k'th element of the original list (both limits included). Start counting the elements with 1.
Example:
*Main> slice ['a','b','c','d','e','f','g','h','i','k'] 3 7
"cdefg
9 Problem 19 - Rotate a list N places to the left.
*Main> rotate ['a','b','c','d','e','f','g','h'] 3
"defghabc"
*Main> rotate ['a','b','c','d','e','f','g','h'] (-2)
"ghabcdef"
(This one is so easy it feels like cheating...) ]]>Sun, 21 Aug 2011 01:58:02 GMThttp://snipplr.com/view/58064/haskell-99-problems--number-18-and-19/(Haskell) Haskell 99 Problems - Solutions to 11 and 12 - rtperson
http://snipplr.com/view/57309/haskell-99-problems--solutions-to-11-and-12/
problem 11, modified run-length encoding
========================================
If an element has no duplicates, mark it as such.
Example:
encodeModified "aaaabccaadeeee"
[Multiple 4 'a',Single 'b',Multiple 2 'c',
Multiple 2 'a',Single 'd',Multiple 4 'e']
problem 12, Decode a run-length encoded list.
=============================================
Given a run-length code list generated as specified in problem 11. Construct its uncompressed version.
Example:
decodeModified
[Multiple 4 'a',Single 'b',Multiple 2 'c',
Multiple 2 'a',Single 'd',Multiple 4 'e']
"aaaabccaadeeee" ]]>Fri, 29 Jul 2011 08:03:55 GMThttp://snipplr.com/view/57309/haskell-99-problems--solutions-to-11-and-12/(Haskell) Run-Length Encoding in Haskell - rtperson
http://snipplr.com/view/57300/runlength-encoding-in-haskell/
Problem 10 of the famous 99 Problems. I got 99 problems, but a Lisp ain't one. ]]>Fri, 29 Jul 2011 06:08:49 GMThttp://snipplr.com/view/57300/runlength-encoding-in-haskell/(Haskell) Euler Problem 4 in Haskell - rtperson
http://snipplr.com/view/54652/euler-problem-4-in-haskell/
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
Find the largest palindrome made from the product of two 3-digit numbers.
There are shorter ways to do this, and I cheat a bit by counting down to 900 rather than 100, but this one short-circuits when it finds the answer, and so is very efficient. ]]>Wed, 01 Jun 2011 00:11:10 GMThttp://snipplr.com/view/54652/euler-problem-4-in-haskell/