Effective Scala Case Class Patterns
Version: 2022.03.02
package org.public_domain.java.utils; | |
import java.util.*; | |
import java.util.Map.Entry; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
/** | |
* File: org.public_domain.java.utils.Memoizer.java | |
* <p> |
//StackOverflow Question: https://stackoverflow.com/q/77362860/501113 | |
//Updated/fixed the 5 code files to incorporate the answer by Turing85: https://stackoverflow.com/users/4216641/turing85 | |
package org.public_domain.java.utils; | |
import java.util.NoSuchElementException; | |
import java.util.Objects; | |
import java.util.Optional; | |
import java.util.function.Consumer; | |
import java.util.function.Function; | |
import java.util.function.Supplier; | |
/** |
Version: 2022.03.02
package org.public_domain | |
import zio.console._ | |
import zio.{ExitCode, UIO, URIO, ZIO} | |
import java.io.IOException | |
object PurelyFunctionalHangman extends zio.App { | |
def run(args: List[String]) : URIO[Console, ExitCode] = | |
hangman.exitCode |
import scalatags.JsDom.all._ | |
val textAreaInput = | |
textarea.render | |
val buttonExecuteTransform = | |
button("Execute Transform").render | |
val textAreaOutput = | |
textarea.render |
//C1 - Initial Scala solution attempt | |
val lettersToDigitsPrefixSize = 3 | |
val letterToDigits = | |
List( | |
'a' -> List(1, 3, 7, 9), | |
'b' -> List(2, 4, 6, 8), | |
'c' -> List(1, 3, 7, 9), | |
'd' -> List(2, 4, 6, 8), |
package org.public_domain.scrabble | |
import scala.util.{Success, Failure, Random, Try} | |
object Bag { | |
//copy and paste directly from provided URL at "Tile count and value ordered by count" | |
// with "Blank" replaced with "_": | |
// http://scrabblewizard.com/scrabble-tile-distribution/ | |
private val countByTileFull = | |
"""E 12 1 |
README.txt - DIY Scala Enumeration | |
Copyright (C) 2014-2016 Jim O'Flaherty | |
Overview: | |
Provide in Scala the closest equivalent to Java Enum | |
- includes decorating each declared Enum member with extended information | |
- guarantees pattern matching exhaustiveness checking | |
- this is not available with scala.Enumeration | |
ScalaOlio library (GPLv3) which contains more up-to-date versions of both `org.scalaolio.util.Enumeration` and `org.scalaolio.util.EnumerationDecorated`: |