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
| public String toString() { | |
| StringBuilder sb = new StringBuilder(); | |
| for(int i = 1; i <= 9; i++) { | |
| Piece piece; | |
| try { | |
| piece = pieceAt(i); | |
| } catch (Exception ex) { | |
| throw new RuntimeException(ex); | |
| } | |
| switch(piece) { |
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
| List<List<Piece>> board = new ArrayList<List<Piece>>(); | |
| for(int i = 0; i < 3; i++) { | |
| List<Piece> row = new ArrayList<Piece>(); | |
| board.add(row); | |
| for(int j = 0; j < 3; j++) { | |
| row.add(Piece.SPACE); | |
| } | |
| } |
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
| char[][] board = new char[3][3]; | |
| // for(int i = 0; i < board.length; i++) { | |
| // board[i] = new int[3]; | |
| // } | |
| for(int i = 0; i < board.length; i++) { | |
| char[] row = board[i]; | |
| for(int j = 0; j < row.length; j++) { | |
| row[j] = 'a' + 3; | |
| } |
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
| package com.kyrlach.hello; | |
| public class BetAction { | |
| private int _amount; | |
| private Face _face; | |
| public BetAction(Face face, int amount) { | |
| _face = face; | |
| _amount = amount; | |
| } |
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
| package com.kyrlach.hello; | |
| import java.util.Random; | |
| import java.util.Scanner; | |
| public class Program { | |
| public static void main(String[] args) { | |
| Random r = new Random(); | |
| Scanner s = new Scanner(System.in); | |
| Integer x = s.nextInt(); |
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
| case class ComputerState(memory: Vector[Int], ptr: Int) | |
| type IntCodeError[A] = Either[String,A] | |
| type IntCodeProgram[A] = StateT[IntCodeError,ComputerState,A] | |
| def pure[A](a: A): IntCodeProgram[A] = StateT.pure(a) | |
| def inspect[A](f: ComputerState => A): IntCodeProgram[A] = StateT.inspect(f) | |
| def mod(f: ComputerState => ComputerState): IntCodeProgram[Unit] = StateT.modify(f) | |
| def error[A](msg: String): IntCodeProgram[A] = StateT.liftF(Left(msg)) |
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 Program { | |
| def main(args: Array[String]): Unit = { | |
| val pgm1 = FrontEnd.clickMe | |
| val pgm2 = FrontEnd.clickMe2 | |
| val init = AppState(-4) | |
| val s1 = App.eval(pgm1, init) | |
| println(s1) |
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
| function compose(f,g) { | |
| return function (a) { | |
| return g(f(a)); | |
| }; | |
| } | |
| function add1(x) { | |
| return x + 1; | |
| } |
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
| {-# LANGUAGE FlexibleInstances #-} | |
| module Intro where | |
| class BenMonoid a where | |
| benappend :: a -> a -> a | |
| benempty :: a | |
| instance BenMonoid (a -> a) where | |
| benappend f g = f . g |
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 Proof1 { | |
| def main(args: Array[String]): Unit = { | |
| trait IsRaining | |
| trait IsCloudy | |
| def proveIt(p: IsRaining): IsCloudy = new IsCloudy {} | |
| proveIt(new IsRaining{}) match { | |
| case _: IsCloudy => println("It's cloudy!") | |
| } |