This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed abstract class Perhaps[+A] { | |
def foreach(f: A => Unit): Unit | |
def map[B](f: A => B): Perhaps[B] | |
def flatMap[B](f: A => Perhaps[B]): Perhaps[B] | |
def withFilter(f: A => Boolean): Perhaps[A] | |
} | |
case class YesItIs[A](value: A) extends Perhaps[A] { | |
override def foreach(f: A => Unit): Unit = f(value) | |
override def map[B](f: A => B): Perhaps[B] = YesItIs(f(value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.{LocalDate, LocalDateTime, LocalTime} | |
/*case */class FullName(val first: String, val last: String) | |
object FullName { | |
def apply(first: String, last: String): FullName = | |
new FullName(first, last) | |
def unapply(full: FullName): Some[(String, String)] = | |
Some((full.first, full.last)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User | |
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User | |
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User | |
[ | |
{ | |
"button": "button1", | |
"count": 1, | |
"modifiers": ["ctrl"], | |
"press_command": "drag_select", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binarySearchIterative(list: Array[Int], target: Int): Int = { | |
var left = 0 | |
var right = list.length-1 | |
while (left<=right) { | |
val mid = left + (right-left)/2 | |
if (list(mid)==target) | |
return mid | |
else if (list(mid)>target) | |
right = mid-1 | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Nano color theme for Scala. | |
## 2013, 2018, Tobias Roeser | |
## | |
syntax "scala" "\.(scala|sbt|sc)$" | |
color green "\<(new|this|transient)\>" | |
color green "\<(catch|do|else|finally|for|if|match|return|switch|throw|try|val|var|while)\>" | |
color green "\<(def|abstract|class|extends|final|import|package|private|protected|public|trait|volatile)\>" | |
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)|\+|\-|\*|\/" | |
color red "@(\\.|[^(])*" | |
color yellow "\<(true|false|null)\>" |