I hereby claim:
- I am cb372 on github.
- I am cb372 (https://keybase.io/cb372) on keybase.
- I have a public key ASCYMnGniI49GycDeF7wL-osskKrzmEbfoRW25L5Xe1H_wo
To claim this, I am signing this object:
| alert('hi') |
I hereby claim:
To claim this, I am signing this object:
Background: I've been writing mostly Scala for the last few years, mostly in FP style. I also have experience writing Java, Ruby, Python, bash and a few other languages.
Caveat: anything below which sounds like a grumble about the language is probably due to ignorance on my part. Please advise/correct me in the comments.
For a more eloquent writeup of a similar topic by somebody who can actually write Rust, see Lloyd's excellent blogpost
| Welcome to the Ammonite Repl 0.8.2 | |
| (Scala 2.12.1 Java 1.8.0_121) | |
| @ import $ivy.`org.typelevel::cats:0.9.0`, cats._, cats.implicits._ | |
| import $ivy.$ , cats._, cats.implicits._ | |
| @ | |
| @ trait Maths[F[_]] { | |
| def int(i: Int): F[Int] | |
| def add(l: F[Int], r: F[Int]): F[Int] | |
| } | |
| defined trait Maths |
| Welcome to the Ammonite Repl 0.8.0 | |
| (Scala 2.11.8 Java 1.8.0_91) | |
| @ import scala.util.Try | |
| import scala.util.Try | |
| @ val listOfTries: List[Try[String]] = List(Try("a"), Try("b"), Try("c")) | |
| listOfTries: List[Try[String]] = List(Success("a"), Success("b"), Success("c")) | |
| // I have a List[Try[String]] but I actually want a Try[List[String]]. |
| import scala.reflect.macros.blackbox | |
| object PrettyPrinting { | |
| /* | |
| * Print a raw AST, nicely indented. | |
| * Pretty fragile, e.g. will get confused by string literals containing commas or parentheses. | |
| */ | |
| def prettyTree(raw: String): String = { | |
| var level = 0 |
| $ curl 'https://content.guardianapis.com/search?tag=us-news/donaldtrump&q=%22reality%20tv%20star%22&page-size=200&from-date=2015-06-01&api-key=<api-key>' | \ | |
| jq -r '.response.results[].webPublicationDate' | \ | |
| cut -c1-7 | \ | |
| sort | \ | |
| uniq -c | \ | |
| gnuplot -e 'set terminal png; set output "test.png"; set xdata time; set timefmt "%Y-%m"; set xrange ["2015-06":"2016-08"]; set format x "%m/%Y"; plot "<cat" using 2:1 with lines title "Reality TV star"' |
| $ ss -s | |
| Total: 185 (kernel 0) | |
| TCP: 43 (estab 28, closed 7, orphaned 0, synrecv 0, timewait 6/0), ports 0 | |
| Transport Total IP IPv6 | |
| * 0 - - | |
| RAW 0 0 0 | |
| UDP 14 8 6 | |
| TCP 36 3 33 | |
| INET 50 11 39 |
| the: 458186 | |
| to: 222092 | |
| of: 201833 | |
| and: 184094 | |
| a: 175172 | |
| in: 158131 | |
| was: 83367 | |
| that: 82857 | |
| for: 73595 | |
| on: 71485 |
| import scala.meta._ | |
| import java.nio.file._ | |
| object CommentWordCount extends App { | |
| val scalaDir = "/Users/chris/code/scala" | |
| val stdlibSrcDir = s"$scalaDir/src/library/scala" | |
| val scalaFileContents: Array[String] = Files.walk(Paths.get(stdlibSrcDir)).toArray.collect { | |
| case p: Path if p.toString.endsWith(".scala") => new String(Files.readAllBytes(p), "UTF-8") |