author | Christian Urban <urbanc@in.tum.de> |
Thu, 26 Jan 2017 01:43:31 +0000 | |
changeset 108 | d39b8733c6ea |
parent 105 | 67ce930b5935 |
child 109 | 293ea84d82ca |
permissions | -rw-r--r-- |
108 | 1 |
// Part 1 about Roman Numerals |
2 |
//============================= |
|
3 |
||
104
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
abstract class RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
case object I extends RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
case object V extends RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
case object X extends RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
case object L extends RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
case object C extends RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
case object D extends RomanDigit |
07780accd5df
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
case object M extends RomanDigit |
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
12 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
13 |
type RomanNumeral = List[RomanDigit] |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
14 |
|
108 | 15 |
|
16 |
// (1) First write a polymorphic function that recursively |
|
17 |
// transforms a list of options into an option of a list. |
|
18 |
// As soon as a None is inside the list, the result is None. |
|
19 |
// Otherwise produce a list of all Some's appended. |
|
20 |
||
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
21 |
def optionlist[A](xs: List[Option[A]]): Option[List[A]] = xs match { |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
22 |
case Nil => Some(Nil) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
23 |
case x::xs => (x, optionlist(xs)) match { |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
24 |
case (None, _) => None |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
25 |
case (_, None) => None |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
26 |
case (Some(y), Some(ys)) => Some(y::ys) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
27 |
} |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
28 |
} |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
29 |
|
108 | 30 |
optionlist(List(Some(1), Some(2), Some(3))) |
31 |
optionlist(List(Some(1), None, Some(3))) |
|
32 |
optionlist(List()) |
|
33 |
||
34 |
// (2) Write a function first a function that converts a character |
|
35 |
// into a roman digit (if possible). Then convert a string into |
|
36 |
// a roman numeral (if possible). If this is not possible, the functions |
|
37 |
// should return None. |
|
38 |
||
39 |
def Char2RomanDigit(c: Char): Option[RomanDigit] = c match { |
|
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
40 |
case 'I' => Some(I) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
41 |
case 'V' => Some(V) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
42 |
case 'X' => Some(X) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
43 |
case 'L' => Some(L) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
44 |
case 'C' => Some(C) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
45 |
case 'D' => Some(D) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
46 |
case 'M' => Some(M) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
47 |
case _ => None |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
48 |
} |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
49 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
50 |
def String2RomanNumeral(s: String) : Option[RomanNumeral] = |
108 | 51 |
optionlist(s.toList.map(Char2RomanDigit)) |
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
52 |
|
108 | 53 |
// some test cases |
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
54 |
String2RomanNumeral("IIII") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
55 |
String2RomanNumeral("IV") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
56 |
String2RomanNumeral("VI") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
57 |
String2RomanNumeral("IX") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
58 |
String2RomanNumeral("MCMLXXIX") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
59 |
String2RomanNumeral("MCMXLIV") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
60 |
String2RomanNumeral("M C M X L I V") // None |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
61 |
|
108 | 62 |
|
63 |
// (3) Write a recursive function RomanNumral2Int that converts a |
|
64 |
// RomanNumeral into an integer. |
|
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
65 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
66 |
def RomanNumeral2Int(rs: RomanNumeral): Int = rs match { |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
67 |
case Nil => 0 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
68 |
case M::r => 1000 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
69 |
case C::M::r => 900 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
70 |
case D::r => 500 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
71 |
case C::D::r => 400 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
72 |
case C::r => 100 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
73 |
case X::C::r => 90 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
74 |
case L::r => 50 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
75 |
case X::L::r => 40 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
76 |
case X::r => 10 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
77 |
case I::X::r => 9 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
78 |
case V::r => 5 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
79 |
case I::V::r => 4 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
80 |
case I::r => 1 + RomanNumeral2Int(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
81 |
} |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
82 |
|
108 | 83 |
// some test cases |
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
84 |
RomanNumeral2Int(List(I,I,I,I)) // 4 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
85 |
RomanNumeral2Int(List(I,V)) // 4 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
86 |
RomanNumeral2Int(List(V,I)) // 6 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
87 |
RomanNumeral2Int(List(I,X)) // 9 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
88 |
RomanNumeral2Int(List(M,C,M,L,X,X,I,X)) // 1979 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
89 |
RomanNumeral2Int(List(M,C,M,X,L,I,V)) // 1944 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
90 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
91 |
|
108 | 92 |
// (4) Write a function that converts a string (containing |
93 |
// a roman numeral) into an integer (if possible). If not |
|
94 |
// this is not possible, the functions should return None. |
|
95 |
||
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
96 |
def String2Int(s: String): Option[Int] = |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
97 |
String2RomanNumeral(s).map(RomanNumeral2Int(_)) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
98 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
99 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
100 |
String2Int("IIII") // 4 invalid |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
101 |
String2Int("IV") // 4 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
102 |
String2Int("VI") // 6 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
103 |
String2Int("IX") // 9 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
104 |
String2Int("MCMLXXIX") // 1979 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
105 |
String2Int("MCMXLIV") // 1944 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
106 |
String2Int("") // 0 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
107 |
String2Int("MDCLXI") // 1661 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
108 |
String2Int("MMMCMXCIX") // 3999 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
109 |
String2Int("XLVIII") // 48 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
110 |
String2Int("MMVIII") // 2008 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
111 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
112 |
String2Int("MMXI") // 2011 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
113 |
String2Int("MIM") // 1999 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
114 |
String2Int("MCMLVI") // 1956 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
115 |
String2Int("XXCIII") // ?? 103 / 83 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
116 |
String2Int("LXXIIX") // ?? 80 / 78 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
117 |
String2Int("IIIIX") // ?? 12 invalid |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
118 |
String2Int("IIXX") // ?? 20 / 18 invalid |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
119 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
120 |
String2Int("III") // 3 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
121 |
String2Int("XXX") // 30 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
122 |
String2Int("CCC") // 300 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
123 |
String2Int("MMM") // 3000 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
124 |
String2Int("VII") // 7 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
125 |
String2Int("LXVI") // 66 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
126 |
String2Int("CL") // 150 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
127 |
String2Int("MCC") // 1200 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
128 |
String2Int("IV") // 4 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
129 |
String2Int("IX") // 9 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
130 |
String2Int("XC") // 90 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
131 |
String2Int("ICM") // ?? 901 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
132 |
String2Int("CIM") // ?? 899 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
133 |
String2Int("MDCLXVI") // 1666 |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
134 |
|
108 | 135 |
String2Int("VIV") // 9, but should be written as IX |
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
136 |
String2Int("IVX") // 14 invalid |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
137 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
138 |
// error cases |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
139 |
String2Int("MC?I") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
140 |
String2Int("abc") |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
141 |
|
108 | 142 |
// (5) The file roman.txt contains a list of roman numerals. |
143 |
// Read in these numerals, convert them into integers and then |
|
144 |
// add them all up. |
|
145 |
||
146 |
import io.Source |
|
147 |
import scala.util._ |
|
148 |
||
149 |
// function for reading files: |
|
150 |
// Source.fromFile("file_name")("ISO-8859-9") |
|
151 |
||
152 |
def addromanfile(filename: String) = { |
|
153 |
val lines = Source.fromFile(filename)("ISO-8859-9").getLines.toList.map(_.trim) |
|
154 |
lines.map(String2Int(_)).flatten.sum |
|
155 |
} |
|
156 |
||
157 |
||
158 |
addromanfile("roman.txt") |
|
159 |
||
160 |
||
161 |
||
162 |
||
105
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
163 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
164 |
def runsAllowed(r: RomanDigit) = r match { |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
165 |
case I | X | C | M => true |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
166 |
case V | L | D => false |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
167 |
} |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
168 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
169 |
def norunsAllowed(r: RomanDigit) = !runsAllowed(r) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
170 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
171 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
172 |
def isValidNumeral(digitList: RomanNumeral): Bool = digitList match { |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
173 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
174 |
// empty list is valid |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
175 |
case Nil => true |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
176 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
177 |
// a following digit that is equal or larger is an error |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
178 |
case d1::d2::_ if (d1 <= d2) => false |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
179 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
180 |
// A single digit is always allowed |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
181 |
case _::ds => isValidNumeral(ds) |
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
182 |
|
67ce930b5935
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
104
diff
changeset
|
183 |
} |