macOS Mojave
Java SE Development Kit 8u111を選択してダウンロードしてくる.
ファイル名はこれ.
jdk-8u111-macosx-x64.dmg
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html
環境変数として以下の二つを設定する.(ここは人によって違う.)
private def collectFirstSome[A, B](seq: Seq[A])(fn: A => Option[B]): Option[B] = { | |
seq.collectFirst(Function.unlift(fn)) | |
} |
import monocle.Monocle.toAppliedFocusOps | |
case class Country(name: String, code: String) | |
case class City(name: String, country: Country) | |
case class Address(number: Int, street: String, city: City) | |
case class Company(name: String, address: Address) |
import cats.Monad | |
import scala.annotation.tailrec | |
object MyOption { | |
implicit def optionMonad: Monad[MyOption] = | |
new Monad[MyOption] { | |
override def pure[A](x: A): MyOption[A] = MySome(x) | |
override def flatMap[A, B](fa: MyOption[A])(f: A => MyOption[B]): MyOption[B] = fa match { | |
case MySome(value) => f(value) |
case class MyOrderedNum(value: Int) extends Ordered[MyOrderedNum] { | |
override def compare(that: MyOrderedNum): Int = { | |
if (this.value < that.value) -1 | |
else if (that.value < this.value) 1 | |
else 0 | |
} | |
} | |
case class MyOrderingNum(value: Int)(implicit ord: Ordering[MyOrderingNum]) { | |
def >(that: MyOrderingNum): Boolean = ord.compare(this, that) > 0 |
import akka.actor.{Actor, ActorSystem, Props} | |
object HelloWorld extends App { | |
val system = ActorSystem("system") | |
val ref = system.actorOf(Props[MyActor]) | |
ref ! "HelloWorld" | |
} | |
class MyActor extends Actor { | |
override def receive: Receive = { | |
case msg => println(msg) |
class Publication(val title: String) | |
class Book(title: String) extends Publication(title) | |
object Library { | |
val books: Set[Book] = Set(new Book("Programming in Scala"), new Book("Walden")) | |
def printBookList(info: Book => AnyRef) = { | |
for (book <- books) println(info(book)) |
macOS Mojave
Java SE Development Kit 8u111を選択してダウンロードしてくる.
ファイル名はこれ.
jdk-8u111-macosx-x64.dmg
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html
環境変数として以下の二つを設定する.(ここは人によって違う.)
def draw_contour(target): | |
n = 100 | |
x = np.linspace(-5, 5, n) | |
y = np.linspace(-5, 5, n) | |
X, Y = np.meshgrid(x, y) | |
Z = target([X, Y]) | |
plt.gca().set_aspect('equal') | |
plt.contour(X, Y, Z, levels=np.linspace(0, 200, 15)) |
#include <stdio.h> | |
#include <stdlib.h> | |
main() { | |
char *a = malloc(1000); | |
char *b = malloc(1000); | |
char *c = malloc(1000); | |
char *d = malloc(1000); | |
printf("a:%lu\n", a); | |
printf("b:%lu\n", b); |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
plt.rcParams['figure.figsize'] = (15.0, 15.0) |