Skip to content

Instantly share code, notes, and snippets.

import {
dateToFormattedString,
dateToFormattedStringForInterviewTime,
toUTC,
utcToJstDateText,
utcToJstTimeText,
} from './date';
describe('toUTC', () => {
it('JSTのDateがUTCに変換される', () => {
@ababup1192
ababup1192 / Main.elm
Created January 10, 2020 14:49
Timer
module Main exposing (main)
import Browser
import Browser.Events exposing (onAnimationFrame)
import Html exposing (Html, button, div, p, text)
import Html.Events exposing (onClick)
import Task
import Time
case class LastName private (value: String) extends AnyVal
object LastName {
private[this] val maxLength = 32
def apply(value: String): LastName = {
val trimmed = value.trim
require(!trimmed.isEmpty && trimmed.length <= maxLength)
new LastName(trimmed)
}
> type Suit = Spade | Diamond | Club | Heart
> type Rank = Ace | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queen | King
> suits = [ Spade, Diamond, Club, Heart ]
[Spade,Diamond,Club,Heart] : List Suit
> ranks = [ Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King ]
[Ace,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Jack,Knight,Queen,King]
: List Rank
> type Card = Card Suit Rank | Joker
> suits |> List.concatMap (\suit -> ranks |> List.map (Card suit) )
module Main exposing (main)
import Browser
import Html exposing (Attribute, Html, button, div, input, label, p, text)
import Html.Attributes exposing (type_)
import Html.Events exposing (on, onClick, targetChecked)
import Json.Decode as JD
type alias Model =
def insertionSort(list: List[Int]): List[Int] = {
list match {
case Nil => Nil
case List(x) => List(x)
case x :: xs => {
insert(x, insertionSort(xs))
}
}
import scala.concurrent._
import scala.concurrent.duration.Duration
import ExecutionContext.Implicits.global
object Main extends App {
def foo(x: Int): Future[Int] =
Future {
println(s"x: $x")
Thread.sleep(300)
type A = { v1: number, v2: number };
type X<K1 extends keyof any, K2 extends keyof any> = {
[key in K1]: A | {
[key in K2]: A
}[]
}
const f = <K1 extends keyof any, K2 extends keyof any>(
obj: X<K1, K2>
// カプセル化してるモジュール部分
type LengthError = (length: number) => string;
type ValidationWithError = {
validations: ValidationErrors[],
errorMessage: string | LengthError
}
const requiredF = (
fieldText: string
): ValidationWithError => {
// privateコンストラクタ
class Foo private(text: String) {
// コンパニオンオブジェクトからは、privateな値(関数)にアクセスできる
def foooo: String = text * Foo.constantValue
}
object Foo {
private val constantValue = 2
// コンパニオンオブジェクトからは、privateコンストラクタにアクセスできる