@@ -26,9 +26,10 @@ line as a sequence of tokens, and I need to decide whether to take action on any
26
26
Let's parse the data. I want to take a String like ` 1 + (2 * (3 * 4) + 5) ` and see it as a simple vector of
27
27
values. The parentheses are always next to a number, but everything else is space delimited. For the numeric
28
28
strings, let's turn them into ` BigInteger ` s right away, since we'll get overflow if we use ` Long ` s. The regex
29
- is a little ugly, but it's not bad. If I put in artifical spaces, you can see it's essentially one big ` or ` ,
30
- and ` re-seq ` returns a sequence of tokens that match the regex. The ` mapv ` only attempts to parse values
31
- that aren't symbols; in theory, I could have done a try-catch parse for each token instead.
29
+ is a little ugly, but it's not bad. If I put in artifical spaces to get ` \d+ | \( | \) | \* ` , you can see
30
+ it's essentially one big ` or ` , and ` re-seq ` returns a sequence of tokens that match the regex. The ` mapv `
31
+ only attempts to parse values that aren't symbols; in theory, I could have done a try-catch parse for each
32
+ token instead.
32
33
33
34
I won't spend any time going over [ Clojure-Java interop] ( https://clojure.org/reference/java_interop ) , but
34
35
suffice it to say that ` (BigInteger. "123") ` , with that extra period, calls the constructor of ` BigInteger `
@@ -166,4 +167,4 @@ valid, so we don't have to worry about running out of operations.
166
167
(ordered-arithmetic tokens other-ops)))
167
168
```
168
169
169
- So yeah, I had a ton of fun with this problem!
170
+ So yeah, I had a ton of fun with this problem!
0 commit comments