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
/** | |
* Pretty prints a Scala value similar to its source represention. | |
* Particularly useful for case classes. | |
* @param a - The value to pretty print. | |
* @param indentSize - Number of spaces for each indent. | |
* @param maxElementWidth - Largest element size before wrapping. | |
* @param depth - Initial depth to pretty print indents. | |
* @return | |
*/ | |
object PrettyPrint { |
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
scalaVersion := "2.11.4" | |
libraryDependencies += "org.scala-lang" % "scalap" % scalaVersion.value | |
InputKey[Unit]("scalap") := { | |
import complete.DefaultParsers._ | |
val classes = spaceDelimited("<class names>").parsed | |
val pathSeparator = java.lang.System.getProperty("path.separator") | |
val classpath = "-classpath" :: (fullClasspath in Compile).value.map(_.data).mkString(pathSeparator) :: Nil | |
val args = "-verbose" :: classpath ::: classes.toList |
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
object foldfun { | |
def foldr[A, B](f: A => B => B)(b: B)(s: Seq[A]): B = s match { | |
case Nil => b | |
case a :: as => | |
f(a)(foldr(f)(b)(as)) | |
} //> foldr: [A, B](f: A => (B => B))(b: B)(s: Seq[A])B | |
foldr { a: String => b: Int => a.toInt * b.toInt }(7)(Seq("1", "2", "3")) | |
//> res0: Int = 42 |
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 | |
# | |
# ========================================================================= | |
# Copyright 2014 Rado Buransky, Dominion Marine Media | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |