<commit_before>### Q.1<br>

```scala
val nonDiscountedPrices = Map(("iphone", 500.50), ("imac", 2040.99), ("apple", 0.50))
val discountedPrices = scala.collection.mutable.Map[String, Double]()
for((k,v) <- nonDiscountedPrices) discountedPrices(k) = v - v * 0.1

```
<br>

### Q.2<br>
I'm going to suck in the text from *Project Gutenberg’s Alice’s Adventures in Wonderland, by <NAME>*  
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
val map = scala.collection.mutable.Map[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map(word) = map.getOrElse(word, 0) + 1
}
map.toString
```
<br>


### Q.3<br>
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
var map = Map[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map = map + ((word, map.getOrElse(word, 0) + 1))
}
map.toString
```
<br>

### Q.4<br>
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
var map = SortedMap[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map = map + ((word, map.getOrElse(word, 0) + 1))
}
map.toString
```
<br>

### Q.5<br>
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
var map = TreeMap[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map = map + ((word, map.getOrElse(word, 0) + 1))
}
map.toString
```
<br>

### Q.6<br>
```scala
val daysOfWeek = Map[String, Int](("SUNDAY", java.util.Calendar.SUNDAY),
                                  ("MONDAY", java.util.Calendar.MONDAY),
                                  ("TUESDAY", java.util.Calendar.TUESDAY),
                                  ("WEDNESDAY", java.util.Calendar.WEDNESDAY),
                                  ("THURSDAY", java.util.Calendar.THURSDAY),
                                  ("FRIDAY", java.util.Calendar.FRIDAY),
                                  ("SATURDAY", java.util.Calendar.SATURDAY))

val linky = LinkedHashMap[String, Any]()
for((day,value) <- daysOfWeek) yield linky.put(day,  {println(s"Inserting $day")})
for((day,value) <- linky) println(day)            

```
<br><commit_msg>Update chapter4.md<commit_after>### Q.1<br>

```scala
val nonDiscountedPrices = Map(("iphone", 500.50), ("imac", 2040.99), ("apple", 0.50))
val discountedPrices = scala.collection.mutable.Map[String, Double]()
for((k,v) <- nonDiscountedPrices) discountedPrices(k) = v - v * 0.1

```
<br>

### Q.2<br>
I'm going to suck in the text from *Project Gutenberg’s Alice’s Adventures in Wonderland, by <NAME>*  
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
val map = scala.collection.mutable.Map[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map(word) = map.getOrElse(word, 0) + 1
}
map.toString
```
<br>


### Q.3<br>
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
var map = Map[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map = map + ((word, map.getOrElse(word, 0) + 1))
}
map.toString
```
<br>

### Q.4<br>
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
var map = SortedMap[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map = map + ((word, map.getOrElse(word, 0) + 1))
}
map.toString
```
<br>

### Q.5<br>
```scala
lazy val in = new java.util.Scanner(new java.net.URL("http://www.gutenberg.org/files/11/11-0.txt").openStream)
var map = TreeMap[String, Int]()
while (in.hasNext()) {
  val word = in.next()
  map = map + ((word, map.getOrElse(word, 0) + 1))
}
map.toString
```
<br>

### Q.6<br>
```scala
val daysOfWeek = Map[String, Int](("SUNDAY", java.util.Calendar.SUNDAY),
                                  ("MONDAY", java.util.Calendar.MONDAY),
                                  ("TUESDAY", java.util.Calendar.TUESDAY),
                                  ("WEDNESDAY", java.util.Calendar.WEDNESDAY),
                                  ("THURSDAY", java.util.Calendar.THURSDAY),
                                  ("FRIDAY", java.util.Calendar.FRIDAY),
                                  ("SATURDAY", java.util.Calendar.SATURDAY))

val linky = LinkedHashMap[String, Any]()
for((day,value) <- daysOfWeek) yield linky.put(day,  {println(s"Inserting $day")})
for((day,value) <- linky) println(day)            

```
<br>

### Q.8<br>
```scala
def minmax(values: Array[Int]) = (values.min, values.max)            

```
<br>

<br>

### Q.9<br>
```scala
def lteqgt(values: Array[Int], v: Int) = (values.filter(_ < v).size, values.filter(_ == v).size, values.filter(_ > v).size)

```
<br>
{'fraction_non_alphanumeric': 0.20020725388601035, 'fraction_numerical': 0.021347150259067357, 'mean_word_length': 2.955737704918033, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1790231', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1814, 'n_words': 361}