Clojure- How would you pull weather data from a link and then work out the warmest day of each calendar month

Viewed 95

So I was surfing through practice problems on 4clojure.com and there has been one problem that I cannot seem to work out, bare in mind clojure is pretty new to me. The question is work out the warmest day of each calendar month from a link they provided? This is one of the hardest questions I've come across online and I genuinely have clue on how to solve this. https://www.metoffice.gov.uk/hadobs/hadcet/cetdl1772on.dat), that is the link they provided alongside this side information of the format of the file. "the format of the file is Column 1: year, Column 2: day, Columns 3-14:daily CET values expressed in tenths of a degree. There are 12 columns; one for each of the 12 months". Been trying for an hour and have made zero progress, it's stressing me out as this is the first time I've struggled with an online practice question :/

1 Answers

Outline:

  • use slurp on the url to get a gigantic string
  • use str/split-lines to get each line
  • use str/split to get each field of each line
  • use Java interop Integer/parseInt to convert "123" -> 123 for each field
  • etc

Please see the list of documentation in the README of this template project.

Especially study the Clojure CheatSheet, plus books like Brave Clojure and Getting Clojure.

Related