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
trait PaymentSource { | |
def accept[T](visitor: PsVisitor[T]) : T | |
} | |
class CreditCard extends PaymentSource{ | |
override def accept[T](visitor: PsVisitor[T]) = { | |
visitor.visit(this) | |
} | |
} |
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 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) ) |
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
package com.czarism.blog | |
import scalaz._ | |
import Scalaz._ | |
/** | |
* Created by tstevens on 7/18/14. | |
*/ | |
object FavorValidation { |
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
/** 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 = ??? |
NewerOlder