This file contains hidden or 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
// it's Seq[_] because we don't really care abou the type, all we're doing is comparing sizes anyway | |
implicit class RichSequence(a: Seq[_]) { | |
def ==(b: Seq[_]): Boolean = a.size == b.size | |
def !=(b: Seq[_]): Boolean = !(a == b) | |
def < (b: Seq[_]): Boolean = a.size < b.size | |
def <=(b: Seq[_]): Boolean = a < b || a == b | |
def > (b: Seq[_]): Boolean = !(a <= b) | |
def >=(b: Seq[_]): Boolean = !(a < b) | |
} |
This file contains hidden or 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
// what it tries to solve: | |
var cond = true | |
if(cond) { | |
while(cond) { | |
// do something | |
} | |
} | |
else { | |
// do something else | |
} |
This file contains hidden or 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
~ com.wausoft.test = | |
+ _ Program = | |
+ main(args: Array[String]): Unit = // unit is equivalent to void | |
printfn("this is a test") | |
- res = add(2, 4) // type inferred to int | |
printfn("result: $res") // example of string interpolation | |
+ add(a: Int, b: Int): Int = a + b |
This file contains hidden or 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
; Scala inspired Lisp | |
; I call it "Stutter" :3 | |
; variable (mutable) definition: | |
(var a 5) | |
; value (immutable) definition: | |
(val b 4) | |
; function definition: |
This file contains hidden or 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
package your.pkg.here | |
import java.security.MessageDigest | |
import java.nio.file.{Files, Paths} | |
object Generator { | |
implicit class Helper(val sc: StringContext) extends AnyVal { | |
def md5(): String = generate("MD5", sc.parts(0)) | |
def sha(): String = generate("SHA", sc.parts(0)) | |
def sha256(): String = generate("SHA-256", sc.parts(0)) |
This file contains hidden or 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
#!/bin/bash | |
function setup-sbt() { | |
# make the basic directories | |
mkdir -p "src/main/scala" # change scala to java if that's what you use | |
mkdir -p "src/main/resources" | |
mkdir -p "src/test/scala" | |
# make build file | |
touch build.sbt |
This file contains hidden or 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.io.File | |
/** | |
* A completely OS-Agnostic way of dealing with java.io.File paths | |
*/ | |
object RichPath { | |
sealed class RichBase[+A](left: A) { | |
/** | |
* Simple enrichment method designed to let you create a java.io.File | |
* by simply writing "folderA" / "folderB" / "folderC" |
This file contains hidden or 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
package io.wausoft | |
import org.joda.time.{Seconds, DateTime} | |
import scala.collection.mutable | |
case class Ack(m: Int, n: Int) | |
object Program extends App { | |
// Basic ackermann without cache, overflows at around Ack(3,11) after a few seconds | |
def compute(a: Ack): Int = a match { |
This file contains hidden or 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
/* | |
* The premise of this is simple; it allows you to chain subroutines without using a block | |
* The idea comes from Haskell's Monads, where by language design you can't normally | |
* predict the order of statement execution due to the language being lazy, | |
* so instead an operator was added that allowed you to call statements sequencially | |
* | |
* Rather than writing something like this: | |
* def printStuff(): Unit = { | |
* println("blah") | |
* println("bloo") |
This file contains hidden or 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
package com.wausoft.core | |
import com.wausoft.dice.Die | |
import com.wausoft.dice.Die.Multiple | |
object Program extends App { | |
// define the five different Grime Dice | |
val red = new Die("red" , 4, 4, 4, 4, 4, 9) | |
val olive = new Die("olive" , 5, 5, 5, 5, 5, 0) | |
val blue = new Die("blue" , 7, 7, 7, 2, 2, 2) |