File tree Expand file tree Collapse file tree 4 files changed +301
-4
lines changed
Expand file tree Collapse file tree 4 files changed +301
-4
lines changed Original file line number Diff line number Diff line change 11Prism . languages . fsharp = Prism . languages . extend ( 'clike' , {
22 'comment' : [
33 {
4- pattern : / ( ^ | [ ^ \\ ] ) \( \* [ \s \S ] * ?\* \) / ,
4+ pattern : / ( ^ | [ ^ \\ ] ) \( \* (? ! \) ) [ \s \S ] * ?\* \) / ,
55 lookbehind : true
66 } ,
77 {
Original file line number Diff line number Diff line change 33(* foo
44bar *)
55
6+ // the next one is not a comment
7+ (*) (*)
8+
69----------------------------------------------------
710
811[
912 ["comment", "// foobar"],
1013 ["comment", "(**)"],
11- ["comment", "(* foo\r\nbar *)"]
14+ ["comment", "(* foo\r\nbar *)"],
15+
16+ ["comment", "// the next one is not a comment"],
17+
18+ ["punctuation", "("],
19+ ["operator", "*"],
20+ ["punctuation", ")"],
21+ ["punctuation", "("],
22+ ["operator", "*"],
23+ ["punctuation", ")"]
1224]
1325
1426----------------------------------------------------
1527
16- Checks for single-line and multi-line comments.
28+ Checks for single-line and multi-line comments.
Original file line number Diff line number Diff line change 1+ let score category (dice:Die list) =
2+ let iDice = dice |> List.map int |> List.sortDescending
3+ let diced = iDice |> List.countBy id |> List.sortByDescending snd
4+ let countScore cat = dice |> List.filter (fun d -> d=cat) |> List.length |> (*) (int cat)
5+ let isStraight = iDice.[0] - iDice.[4] = 4
6+
7+ match category , List.map snd diced with
8+ | Yacht , [5] -> 50
9+ | Ones , _ -> countScore Die.One
10+ | Twos , _ -> countScore Die.Two
11+ | Threes , _ -> countScore Die.Three
12+ | Fours , _ -> countScore Die.Four
13+ | Fives , _ -> countScore Die.Five
14+ | Sixes , _ -> countScore Die.Six
15+ | FourOfAKind , [4;1]
16+ | FourOfAKind , [5] -> iDice |> List.head |> (*) 4
17+ | LittleStraight, [1;1;1;1;1] when isStraight && iDice.[0] = 5 -> 30
18+ | BigStraight , [1;1;1;1;1] when isStraight && iDice.[0] = 6 -> 30
19+ | FullHouse , [3;2]
20+ | Choice , _ -> iDice |> List.sum
21+ | _ , _ -> 0
22+
23+ ----------------------------------------------------
24+
25+ [
26+ ["keyword", "let"],
27+ " score category ",
28+ ["punctuation", "("],
29+ "dice",
30+ ["punctuation", ":"],
31+ ["class-name", ["Die"]],
32+ " list",
33+ ["punctuation", ")"],
34+ ["operator", "="],
35+
36+ ["keyword", "let"],
37+ " iDice ",
38+ ["operator", "="],
39+ " dice ",
40+ ["operator", "|>"],
41+ " List",
42+ ["punctuation", "."],
43+ "map int ",
44+ ["operator", "|>"],
45+ " List",
46+ ["punctuation", "."],
47+ "sortDescending\r\n ",
48+
49+ ["keyword", "let"],
50+ " diced ",
51+ ["operator", "="],
52+ " iDice ",
53+ ["operator", "|>"],
54+ " List",
55+ ["punctuation", "."],
56+ "countBy id ",
57+ ["operator", "|>"],
58+ " List",
59+ ["punctuation", "."],
60+ "sortByDescending snd\r\n ",
61+
62+ ["keyword", "let"],
63+ " countScore cat ",
64+ ["operator", "="],
65+ " dice ",
66+ ["operator", "|>"],
67+ " List",
68+ ["punctuation", "."],
69+ "filter ",
70+ ["punctuation", "("],
71+ ["keyword", "fun"],
72+ " d ",
73+ ["operator", "->"],
74+ " d",
75+ ["operator", "="],
76+ "cat",
77+ ["punctuation", ")"],
78+ ["operator", "|>"],
79+ " List",
80+ ["punctuation", "."],
81+ "length ",
82+ ["operator", "|>"],
83+ ["punctuation", "("],
84+ ["operator", "*"],
85+ ["punctuation", ")"],
86+ ["punctuation", "("],
87+ "int cat",
88+ ["punctuation", ")"],
89+
90+ ["keyword", "let"],
91+ " isStraight ",
92+ ["operator", "="],
93+ " iDice",
94+ ["punctuation", "."],
95+ ["punctuation", "["],
96+ ["number", "0"],
97+ ["punctuation", "]"],
98+ ["operator", "-"],
99+ " iDice",
100+ ["punctuation", "."],
101+ ["punctuation", "["],
102+ ["number", "4"],
103+ ["punctuation", "]"],
104+ ["operator", "="],
105+ ["number", "4"],
106+
107+ ["keyword", "match"],
108+ " category ",
109+ ["punctuation", ","],
110+ " List",
111+ ["punctuation", "."],
112+ "map snd diced ",
113+ ["keyword", "with"],
114+
115+ ["operator", "|"],
116+ " Yacht ",
117+ ["punctuation", ","],
118+ ["punctuation", "["],
119+ ["number", "5"],
120+ ["punctuation", "]"],
121+ ["operator", "->"],
122+ ["number", "50"],
123+
124+ ["operator", "|"],
125+ " Ones ",
126+ ["punctuation", ","],
127+ " _ ",
128+ ["operator", "->"],
129+ " countScore Die",
130+ ["punctuation", "."],
131+ "One\r\n ",
132+
133+ ["operator", "|"],
134+ " Twos ",
135+ ["punctuation", ","],
136+ " _ ",
137+ ["operator", "->"],
138+ " countScore Die",
139+ ["punctuation", "."],
140+ "Two\r\n ",
141+
142+ ["operator", "|"],
143+ " Threes ",
144+ ["punctuation", ","],
145+ " _ ",
146+ ["operator", "->"],
147+ " countScore Die",
148+ ["punctuation", "."],
149+ "Three\r\n ",
150+
151+ ["operator", "|"],
152+ " Fours ",
153+ ["punctuation", ","],
154+ " _ ",
155+ ["operator", "->"],
156+ " countScore Die",
157+ ["punctuation", "."],
158+ "Four\r\n ",
159+
160+ ["operator", "|"],
161+ " Fives ",
162+ ["punctuation", ","],
163+ " _ ",
164+ ["operator", "->"],
165+ " countScore Die",
166+ ["punctuation", "."],
167+ "Five\r\n ",
168+
169+ ["operator", "|"],
170+ " Sixes ",
171+ ["punctuation", ","],
172+ " _ ",
173+ ["operator", "->"],
174+ " countScore Die",
175+ ["punctuation", "."],
176+ "Six\r\n ",
177+
178+ ["operator", "|"],
179+ " FourOfAKind ",
180+ ["punctuation", ","],
181+ ["punctuation", "["],
182+ ["number", "4"],
183+ ["punctuation", ";"],
184+ ["number", "1"],
185+ ["punctuation", "]"],
186+
187+ ["operator", "|"],
188+ " FourOfAKind ",
189+ ["punctuation", ","],
190+ ["punctuation", "["],
191+ ["number", "5"],
192+ ["punctuation", "]"],
193+ ["operator", "->"],
194+ " iDice ",
195+ ["operator", "|>"],
196+ " List",
197+ ["punctuation", "."],
198+ "head ",
199+ ["operator", "|>"],
200+ ["punctuation", "("],
201+ ["operator", "*"],
202+ ["punctuation", ")"],
203+ ["number", "4"],
204+
205+ ["operator", "|"],
206+ " LittleStraight",
207+ ["punctuation", ","],
208+ ["punctuation", "["],
209+ ["number", "1"],
210+ ["punctuation", ";"],
211+ ["number", "1"],
212+ ["punctuation", ";"],
213+ ["number", "1"],
214+ ["punctuation", ";"],
215+ ["number", "1"],
216+ ["punctuation", ";"],
217+ ["number", "1"],
218+ ["punctuation", "]"],
219+ ["keyword", "when"],
220+ " isStraight ",
221+ ["operator", "&&"],
222+ " iDice",
223+ ["punctuation", "."],
224+ ["punctuation", "["],
225+ ["number", "0"],
226+ ["punctuation", "]"],
227+ ["operator", "="],
228+ ["number", "5"],
229+ ["operator", "->"],
230+ ["number", "30"],
231+
232+ ["operator", "|"],
233+ " BigStraight ",
234+ ["punctuation", ","],
235+ ["punctuation", "["],
236+ ["number", "1"],
237+ ["punctuation", ";"],
238+ ["number", "1"],
239+ ["punctuation", ";"],
240+ ["number", "1"],
241+ ["punctuation", ";"],
242+ ["number", "1"],
243+ ["punctuation", ";"],
244+ ["number", "1"],
245+ ["punctuation", "]"],
246+ ["keyword", "when"],
247+ " isStraight ",
248+ ["operator", "&&"],
249+ " iDice",
250+ ["punctuation", "."],
251+ ["punctuation", "["],
252+ ["number", "0"],
253+ ["punctuation", "]"],
254+ ["operator", "="],
255+ ["number", "6"],
256+ ["operator", "->"],
257+ ["number", "30"],
258+
259+ ["operator", "|"],
260+ " FullHouse ",
261+ ["punctuation", ","],
262+ ["punctuation", "["],
263+ ["number", "3"],
264+ ["punctuation", ";"],
265+ ["number", "2"],
266+ ["punctuation", "]"],
267+
268+ ["operator", "|"],
269+ " Choice ",
270+ ["punctuation", ","],
271+ " _ ",
272+ ["operator", "->"],
273+ " iDice ",
274+ ["operator", "|>"],
275+ " List",
276+ ["punctuation", "."],
277+ "sum\r\n ",
278+
279+ ["operator", "|"],
280+ " _ ",
281+ ["punctuation", ","],
282+ " _ ",
283+ ["operator", "->"],
284+ ["number", "0"]
285+ ]
You can’t perform that action at this time.
0 commit comments