Skip to content

Instantly share code, notes, and snippets.

View OleTraveler's full-sized avatar
🤷‍♂️
Dunno

Travis Stevens OleTraveler

🤷‍♂️
Dunno
View GitHub Profile
@OleTraveler
OleTraveler / gist:04fe8eacd3326f250c9c
Created August 13, 2014 06:10
Hibernate Inheritance and Using Pattern Matching
trait PaymentSource {
def accept[T](visitor: PsVisitor[T]) : T
}
class CreditCard extends PaymentSource{
override def accept[T](visitor: PsVisitor[T]) = {
visitor.visit(this)
}
}
def maxTen(i: Int) =
if (i <= 10) \/-(i)
else "Must be less than ten"
def divisibleByTwo(i: Int) =
if (i % 2 == 0) == 0 \/-(i)
else "Must be divisable by two"
def whatType(input: Int): ???[NonEmptyList[String], Int] =
( parseInt(input) |@| divisibleByTow(input) )
@OleTraveler
OleTraveler / gist:525ba037ae94625ba822
Created July 20, 2014 20:48
Code Written for blog entry:
package com.czarism.blog
import scalaz._
import Scalaz._
/**
* Created by tstevens on 7/18/14.
*/
object FavorValidation {
@OleTraveler
OleTraveler / gist:888325c6a9174cfaa78a
Created August 26, 2015 21:56
Interview Question
/** Determine if the list l contains a sequence which follows the recurrence relation for the function f.
*
* A recurrence relation is where numbers in the list determine the rest of the list, for example the Fibonacci sequence
* is defined for function plus and you could call this function with the parameters l = List(0,1,1,2,3,5,8,13), f = _ + +
*
* See InterviewSpec for a test example.
* */
def isRecurrenceRelation(l: List[Int], f: (Int, Int) => Int) : Boolean = ???