aboutsummaryrefslogtreecommitdiff
path: root/js/codemirror/mode/haskell/index.html
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-15 16:09:47 -0800
committerValerio Virgillito2012-02-15 16:09:47 -0800
commitd366c0bd1af6471511217ed574083e15059519b5 (patch)
treec8c9f9af761457e3c5f4c6774fb0fbba851df0c4 /js/codemirror/mode/haskell/index.html
parent997ce3fb65f27b3d6f331f63b5dc22d3c7fb8f1e (diff)
parentb85bfb54aaca3ccca3c1ef09115de925cd67f4e9 (diff)
downloadninja-d366c0bd1af6471511217ed574083e15059519b5.tar.gz
Merge branch 'refs/heads/integration'
Diffstat (limited to 'js/codemirror/mode/haskell/index.html')
-rw-r--r--js/codemirror/mode/haskell/index.html60
1 files changed, 0 insertions, 60 deletions
diff --git a/js/codemirror/mode/haskell/index.html b/js/codemirror/mode/haskell/index.html
deleted file mode 100644
index 6ea7f5ed..00000000
--- a/js/codemirror/mode/haskell/index.html
+++ /dev/null
@@ -1,60 +0,0 @@
1<!doctype html>
2<html>
3 <head>
4 <title>CodeMirror 2: Haskell mode</title>
5 <link rel="stylesheet" href="../../lib/codemirror.css">
6 <script src="../../lib/codemirror.js"></script>
7 <script src="haskell.js"></script>
8 <link rel="stylesheet" href="../../theme/elegant.css">
9 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10 <link rel="stylesheet" href="../../css/docs.css">
11 </head>
12 <body>
13 <h1>CodeMirror 2: Haskell mode</h1>
14
15<form><textarea id="code" name="code">
16module UniquePerms (
17 uniquePerms
18 )
19where
20
21-- | Find all unique permutations of a list where there might be duplicates.
22uniquePerms :: (Eq a) => [a] -> [[a]]
23uniquePerms = permBag . makeBag
24
25-- | An unordered collection where duplicate values are allowed,
26-- but represented with a single value and a count.
27type Bag a = [(a, Int)]
28
29makeBag :: (Eq a) => [a] -> Bag a
30makeBag [] = []
31makeBag (a:as) = mix a $ makeBag as
32 where
33 mix a [] = [(a,1)]
34 mix a (bn@(b,n):bs) | a == b = (b,n+1):bs
35 | otherwise = bn : mix a bs
36
37permBag :: Bag a -> [[a]]
38permBag [] = [[]]
39permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs
40 where
41 oneOfEach [] = []
42 oneOfEach (an@(a,n):bs) =
43 let bs' = if n == 1 then bs else (a,n-1):bs
44 in (a,bs') : mapSnd (an:) (oneOfEach bs)
45
46 apSnd f (a,b) = (a, f b)
47 mapSnd = map . apSnd
48</textarea></form>
49
50 <script>
51 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
52 lineNumbers: true,
53 matchBrackets: true,
54 theme: "elegant"
55 });
56 </script>
57
58 <p><strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p>
59 </body>
60</html>