This file contains 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
import scala.io.Source | |
def widthOfLength(s: String) = s.length.toString.length | |
def format(maxWidth : Int, line : String) = { | |
val padding = " " * (maxWidth - widthOfLength(line)) | |
padding + line.length + " | " + line | |
} | |
def formatLines(lines : List[String]) : List[String] = { |
This file contains 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
import org.scalacheck.Properties | |
import org.scalacheck.Prop._ | |
import Cop3_6._ | |
/** | |
* ScalaCheck を使った自動テスト | |
*/ | |
object Check extends Properties("コップ本3.6") { | |
//リストの要素がすべて同じかどうか判定する便利関数 |
This file contains 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
let document = Dom_html.document;; | |
let window = Dom_html.window;; | |
print_endline "Hello, world!";; | |
window##alert(Js.string "Hello");; |
This file contains 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
let document = Dom_html.document;; | |
let window = Dom_html.window;; | |
print_endline "Hello, world!";; | |
window##alert(Js.string "Hello");; |
This file contains 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
let document = Dom_html.document;; | |
let window = Dom_html.window;; | |
let b = Dom_html.createInput ~_type:(Js.string "button") document;; | |
b##value <- Js.string "Push Me";; | |
b##onclick <- Dom_html.handler (fun _ -> window##alert(Js.string "hello"); Js._true);; | |
let top = Js.Opt.get (document##getElementById(Js.string "toplevel")) (fun () -> assert false);; | |
Dom.appendChild top b;; |
This file contains 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
Js.Unsafe.set | |
(Dom_html.document##body##style) | |
"webkitTransform" | |
"rotate(30rad)";; |
This file contains 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
Require Import Psatz ZArith. | |
Open Scope Z_scope. | |
Goal forall x y, 27 <= 11 * x + 13 * y <= 45 -> -10 <= 7 * x - 9 * y <= 4 -> False. | |
intros. | |
lia. |
This file contains 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
import fj.F; | |
import fj.Unit; | |
import fj.data.Option; | |
public class Main { | |
static void take1() { | |
for (final String s : foo()) { | |
for (final Float f : bar()) { | |
for (final Integer i : baz()) { |
This file contains 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
(* ベクトルの内積 *) | |
let ( ** ) (x,y) (a,b) = x *. a +. y *. b | |
(* 2点間の距離 *) | |
let distance (x,y) (a,b) = sqrt ((x -. a) * (x -. a) + (y -. b) * (y -. b)) | |
(* 点(px,py) と 直線(x1,y1)(x2,y2)の距離 *) | |
let distance_to_line (x1,y1) (x2,y2) (px,py) = | |
let b, c = (x2-.x1,y2-.y1), (px-.x1,py-.y1) in | |
let dotprod = b ** c in |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Proofcafe | |
{ | |
class TaskMonad |
OlderNewer