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 isin | |
object Isin { | |
// based on http://en.wikipedia.org/wiki/International_Securities_Identification_Number | |
def isIsin(code: String): Boolean = { | |
val digits: String = code.init.map(c => BigInt(c.toString, 36)).mkString | |
val parity = digits.size & 1 | |
val total: Int = digits.zipWithIndex.map { | |
case (c: Char, i: Int) => |
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.whatever | |
{ | |
import org.flexunit.asserts.assertEquals; | |
import org.granite.math.BigDecimal; | |
public class BigDecimalTest { | |
public function BigDecimalTest() { | |
} |
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 mmind; | |
import com.google.common.collect.AbstractIterator; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
public class Mmind { |
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 com.google.common.base.Function; | |
import com.google.common.base.Optional; | |
import org.junit.Test; | |
import javax.annotation.Nullable; | |
import static org.fest.assertions.Assertions.assertThat; | |
public class OptionalTest { |
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 collect; | |
import com.google.common.base.Function; | |
public abstract class Option<T> { | |
private static final Option<?> ABSENT = new Absent<Object>(); | |
public static <T> Option<T> of(T value) { | |
return new Present<T>(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
package my.util; | |
import java.util.Collections; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.NoSuchElementException; | |
import java.util.function.Function; | |
public abstract class Option<T> implements Iterable<T> { |
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
object App { | |
val banks: Map[String, Set[Account]] = Map( | |
"BGP" -> Set( | |
Account("CC1", "BGP", "Alice", 5000) | |
), | |
"La Postale" -> Set( | |
Account("CP1", "La Postale", "Alice", 2000) | |
), | |
"Societe Geniale" -> Set(), |
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 com.sun.net.httpserver.HttpExchange; | |
import com.sun.net.httpserver.HttpServer; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
public class WebMain { | |
public static void main(String[] args) throws IOException { | |
WebServer.serve(8080, "/").withRoute( |
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 test.kata_digit; | |
import static org.fest.assertions.api.Assertions.assertThat; | |
import org.junit.Test; | |
public class DigitTest { | |
@Test | |
public void should_get_digital_one_when_1() throws Exception { |
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
object Point { | |
trait PointAdder[P1, P2] { | |
def add(p1: P1, p2: P2): Point3D | |
} | |
case class Point2D(x: Int, y: Int) | |
case class Point3D(x: Int, y: Int, z: Int) | |
implicit object Point2DAdder extends PointAdder[Point2D, Point2D] { |
OlderNewer