Skip to content

Instantly share code, notes, and snippets.

View vijexa's full-sized avatar
💻
Monkey with a keyboard

Viktors Nuždins vijexa

💻
Monkey with a keyboard
View GitHub Profile
@vijexa
vijexa / 1-factorial-test.scala
Last active October 26, 2020 13:42
I wanted to quickly test if LazyList will actually make repeated factorial computations faster than recursion/tail recursion. Spoiler: it depends. It seems like for primitives repeated calculation is much faster than searching value on the list. But if we are using BigInt, LazyList actually performs far better than recursive alternatives.
object Main extends App {
import scala.annotation.tailrec
val facL: LazyList[Long] = 1l #:: facL zip LazyList.from(0) map {
case (prev, i) =>
if (i != 0) prev * i
else 1
}
def facR (n: Int): Long =
@vijexa
vijexa / init-workspace
Created June 21, 2018 20:43
Launches chrome window for multimedia purposes on the left, for programming purposes on the right, and VS Code in Zen mode in the middle
#!/bin/bash
# launches chrome window for multimedia purposes on the left, for programming purposes
# on the right, and VS Code in Zen mode in the middle
# -s flag enables spotify because i like it
wmctrl -s 1
google-chrome --new-window vk.com &
if [ $1 = '-s' ]
then
spotify &