Today’s problem was all about reading numbers from the input file, so I first added the words function from Haskell to my utility library:

def String.words (s : String) : List String :=
s.splitOn " " |> List.filter (!·.isEmpty)

In the problem, we also read in the operations to be performed on the numbers. I initially parsed '+' and '*' into a pair of the function and the neutral element for the operation, but then found out that List.sum will use the Add and Zero instance for the type instance and do the right thing. However, there was no List.prod in Lean’s standard library1, so I d…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help